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