mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
smooth out switching between movement states
This commit is contained in:
parent
75619c21a1
commit
d9acfbb431
3 changed files with 17 additions and 2 deletions
|
@ -13,6 +13,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
public abstract AnimId movementAnim { get; }
|
||||
public abstract AnimId movementWeaponAnim { get; }
|
||||
|
||||
public virtual float TimeUntilStateCanBeSwitchedToOtherMovementState => PedManager.Instance.timeUntilMovementStateCanBeSwitchedToOtherMovementState;
|
||||
public virtual float TimeUntilStateCanBeEnteredFromOtherMovementState => PedManager.Instance.timeUntilMovementStateCanBeEnteredFromOtherMovementState;
|
||||
|
||||
|
||||
|
||||
public override void UpdateState() {
|
||||
|
@ -36,7 +39,15 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
protected virtual void SwitchToMovementState()
|
||||
{
|
||||
BaseMovementState.SwitchToMovementStateBasedOnInput (m_ped);
|
||||
if (this.TimeSinceActivated <= this.TimeUntilStateCanBeSwitchedToOtherMovementState)
|
||||
return;
|
||||
|
||||
System.Type type = BaseMovementState.GetMovementStateToSwitchToBasedOnInput(m_ped);
|
||||
var state = (BaseMovementState) m_ped.GetStateOrLogError(type);
|
||||
if (state.TimeSinceDeactivated <= state.TimeUntilStateCanBeEnteredFromOtherMovementState)
|
||||
return;
|
||||
|
||||
m_ped.SwitchState(type);
|
||||
}
|
||||
|
||||
public static void SwitchToMovementStateBasedOnInput (Ped ped)
|
||||
|
|
|
@ -10,8 +10,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
public override AnimId movementAnim { get { return new AnimId (AnimGroup.WalkCycle, AnimIndex.Idle); } }
|
||||
public override AnimId movementWeaponAnim { get { return m_ped.CurrentWeapon.IdleAnim; } }
|
||||
|
||||
public override float TimeUntilStateCanBeSwitchedToOtherMovementState => 0f;
|
||||
|
||||
public override void UpdateState() {
|
||||
|
||||
public override void UpdateState() {
|
||||
|
||||
base.UpdateState();
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
public float minTimeToReturnToAimState = 0.33f;
|
||||
public float minTimeToReturnToNonAimStateFromAimState = 0.33f;
|
||||
public float timeUntilMovementStateCanBeSwitchedToOtherMovementState = 0.166f;
|
||||
public float timeUntilMovementStateCanBeEnteredFromOtherMovementState = 0.166f;
|
||||
|
||||
[Header("Camera")]
|
||||
|
||||
|
|
Loading…
Reference in a new issue