diff --git a/Assets/Scripts/Behaviours/Ped/States/BaseMovementState.cs b/Assets/Scripts/Behaviours/Ped/States/BaseMovementState.cs index 39beceb6..26e7351f 100644 --- a/Assets/Scripts/Behaviours/Ped/States/BaseMovementState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/BaseMovementState.cs @@ -140,7 +140,11 @@ namespace SanAndreasUnity.Behaviours.Peds.States public override void OnCrouchButtonPressed () { if (m_isServer) - m_ped.SwitchState(); + { + var crouchState = m_ped.GetState(); + if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, crouchState)) + m_ped.SwitchState(crouchState.GetType()); + } else base.OnCrouchButtonPressed(); } diff --git a/Assets/Scripts/Behaviours/Ped/States/CrouchMoveState.cs b/Assets/Scripts/Behaviours/Ped/States/CrouchMoveState.cs index 4d2dbdae..4b2ff4b4 100644 --- a/Assets/Scripts/Behaviours/Ped/States/CrouchMoveState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/CrouchMoveState.cs @@ -38,7 +38,11 @@ namespace SanAndreasUnity.Behaviours.Peds.States public override void OnCrouchButtonPressed () { if (m_isServer) - m_ped.SwitchState(); + { + var standState = m_ped.GetState(); + if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, standState)) + m_ped.SwitchState(standState.GetType()); + } else base.OnCrouchButtonPressed(); } diff --git a/Assets/Scripts/Behaviours/Ped/States/CrouchState.cs b/Assets/Scripts/Behaviours/Ped/States/CrouchState.cs index 67946aef..2daf0e73 100644 --- a/Assets/Scripts/Behaviours/Ped/States/CrouchState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/CrouchState.cs @@ -85,8 +85,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States // switch to stand state if (m_isServer) - m_ped.SwitchState(); - else + { + var standState = m_ped.GetState(); + if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, standState)) + m_ped.SwitchState(standState.GetType()); + } + else base.OnCrouchButtonPressed(); }