mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 16:27:19 +00:00
smooth out switching between crouch states and stand state
This commit is contained in:
parent
b9a57dd79e
commit
f8e8f4aeb8
3 changed files with 16 additions and 4 deletions
|
@ -140,7 +140,11 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
public override void OnCrouchButtonPressed ()
|
||||
{
|
||||
if (m_isServer)
|
||||
m_ped.SwitchState<CrouchState>();
|
||||
{
|
||||
var crouchState = m_ped.GetState<CrouchState>();
|
||||
if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, crouchState))
|
||||
m_ped.SwitchState(crouchState.GetType());
|
||||
}
|
||||
else
|
||||
base.OnCrouchButtonPressed();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,11 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
public override void OnCrouchButtonPressed ()
|
||||
{
|
||||
if (m_isServer)
|
||||
m_ped.SwitchState<StandState>();
|
||||
{
|
||||
var standState = m_ped.GetState<StandState>();
|
||||
if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, standState))
|
||||
m_ped.SwitchState(standState.GetType());
|
||||
}
|
||||
else
|
||||
base.OnCrouchButtonPressed();
|
||||
}
|
||||
|
|
|
@ -85,8 +85,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
// switch to stand state
|
||||
|
||||
if (m_isServer)
|
||||
m_ped.SwitchState<StandState>();
|
||||
else
|
||||
{
|
||||
var standState = m_ped.GetState<StandState>();
|
||||
if (BaseMovementState.EnoughTimePassedToSwitchBetweenMovementStates(this, standState))
|
||||
m_ped.SwitchState(standState.GetType());
|
||||
}
|
||||
else
|
||||
base.OnCrouchButtonPressed();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue