Disable sprinting when aiming
This commit is contained in:
parent
1a80c19355
commit
0ac395b1fb
@ -272,7 +272,7 @@ void game::Character::UpdateMovement()
|
||||
{
|
||||
walking = true;
|
||||
|
||||
if (in_ & (1 << CIN_SPRINT))
|
||||
if ((in_ & (1 << CIN_SPRINT)) && can_sprint_)
|
||||
running = true;
|
||||
|
||||
const bool directional = (movement_ == CMT_DIRECTIONAL);
|
||||
|
||||
@ -100,6 +100,7 @@ public:
|
||||
~Character() override;
|
||||
|
||||
protected:
|
||||
void SetCanSprint(bool can_sprint) { can_sprint_ = can_sprint; }
|
||||
void SetIdleAnim(const std::string& anim_name);
|
||||
void SetWalkAnim(const std::string& anim_name);
|
||||
void SetRunAnim(const std::string& anim_name);
|
||||
@ -148,6 +149,7 @@ private:
|
||||
// glm::vec3 velocity_ = glm::vec3(0.0f);
|
||||
|
||||
CharacterInputFlags in_ = 0;
|
||||
bool can_sprint_ = true;
|
||||
|
||||
btCapsuleShapeZ bt_shape_;
|
||||
float z_offset_ = 0.0f; // offset of controller from root
|
||||
|
||||
@ -254,28 +254,33 @@ void game::HumanCharacter::EnterActionState(ActionState state)
|
||||
if (state_ == HS_ON_FOOT)
|
||||
SetIdleAnim("idle_relaxed");
|
||||
SetAiming(false);
|
||||
SetCanSprint(true);
|
||||
PlayActionAnim("rifle_idle");
|
||||
SetViewItem("airsniper");
|
||||
break;
|
||||
|
||||
case ACTION_AIM:
|
||||
SetViewItem("airsniper");
|
||||
SetAiming(true);
|
||||
SetCanSprint(false);
|
||||
PlayActionAnim("rifle_aim", 3.0f);
|
||||
break;
|
||||
|
||||
case ACTION_AIMING:
|
||||
SetAiming(true);
|
||||
SetCanSprint(false);
|
||||
PlayActionAnim("rifle_aiming");
|
||||
break;
|
||||
|
||||
case ACTION_FIRE:
|
||||
SetAiming(true);
|
||||
SetCanSprint(false);
|
||||
PlayActionAnim("rifle_fire");
|
||||
Fire();
|
||||
break;
|
||||
|
||||
case ACTION_UNAIM:
|
||||
SetAiming(false);
|
||||
SetCanSprint(false);
|
||||
PlayActionAnim("rifle_aim", -3.0f);
|
||||
break;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user