mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
smooth out switching between aim movement states
This commit is contained in:
parent
6037568f0a
commit
abac2b54f5
3 changed files with 31 additions and 3 deletions
|
@ -23,9 +23,13 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
protected bool m_wasAimingBackWithAWAWeapon = false;
|
||||
protected float m_timeSinceAimingBackWithAWAWeapon = 0f;
|
||||
|
||||
public virtual float TimeUntilStateCanBeSwitchedToOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState;
|
||||
public virtual float TimeUntilStateCanBeEnteredFromOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState;
|
||||
|
||||
|
||||
public override void OnBecameActive()
|
||||
|
||||
|
||||
public override void OnBecameActive()
|
||||
{
|
||||
base.OnBecameActive();
|
||||
|
||||
|
@ -108,10 +112,30 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
protected virtual bool SwitchToOtherAimMovementState ()
|
||||
{
|
||||
BaseAimMovementState.SwitchToAimMovementStateBasedOnInput (m_ped);
|
||||
System.Type type = GetAimMovementStateToSwitchToBasedOnInput(m_ped);
|
||||
var state = (BaseAimMovementState)m_ped.GetStateOrLogError(type);
|
||||
|
||||
if (!EnoughTimePassedToSwitchBetweenAimMovementStates(this, state))
|
||||
return false;
|
||||
|
||||
m_ped.SwitchState(type);
|
||||
|
||||
return ! this.IsActiveState;
|
||||
}
|
||||
|
||||
public static bool EnoughTimePassedToSwitchBetweenAimMovementStates(
|
||||
BaseAimMovementState currentState,
|
||||
BaseAimMovementState targetState)
|
||||
{
|
||||
if (currentState.TimeSinceActivated < currentState.TimeUntilStateCanBeSwitchedToOtherAimMovementState)
|
||||
return false;
|
||||
|
||||
if (targetState.TimeSinceDeactivated < targetState.TimeUntilStateCanBeEnteredFromOtherAimMovementState)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool SwitchToFallingState ()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -9,8 +9,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
{
|
||||
public override AnimId aimWithArm_LowerAnim { get { return m_ped.CurrentWeapon.IdleAnim; } }
|
||||
|
||||
public override float TimeUntilStateCanBeSwitchedToOtherAimMovementState => 0f;
|
||||
|
||||
public override void OnBecameActive ()
|
||||
|
||||
public override void OnBecameActive ()
|
||||
{
|
||||
base.OnBecameActive ();
|
||||
// m_ped.PlayerModel.PlayAnim (AnimGroup.MyWalkCycle, AnimIndex.GUN_STAND);
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
public float minTimeToReturnToNonAimStateFromAimState = 0.33f;
|
||||
public float timeUntilMovementStateCanBeSwitchedToOtherMovementState = 0.166f;
|
||||
public float timeUntilMovementStateCanBeEnteredFromOtherMovementState = 0.166f;
|
||||
public float timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState = 0.166f;
|
||||
public float timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState = 0.166f;
|
||||
|
||||
[Header("Camera")]
|
||||
|
||||
|
|
Loading…
Reference in a new issue