mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
add logic for waiting before switching to aim states
This commit is contained in:
parent
fda6997579
commit
bef07417b3
3 changed files with 17 additions and 2 deletions
|
@ -70,12 +70,25 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
protected virtual void SwitchToAimState()
|
||||
{
|
||||
if (m_ped.IsAimOn && m_ped.IsHoldingWeapon)
|
||||
if (m_ped.IsAimOn && m_ped.IsHoldingWeapon && EnoughTimePassedToSwitchToAimState(m_ped))
|
||||
{
|
||||
BaseAimMovementState.SwitchToAimMovementStateBasedOnInput (m_ped);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool EnoughTimePassedToSwitchToAimState(Ped ped)
|
||||
{
|
||||
var aimStates = ped.CachedAimStates;
|
||||
|
||||
for (int i = 0; i < aimStates.Count; i++)
|
||||
{
|
||||
if (Time.time - aimStates[i].LastTimeWhenDeactivated < PedManager.Instance.minTimeToReturnToAimState)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void UpdateAnims ()
|
||||
{
|
||||
if (m_ped.CurrentWeapon != null)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
public static void SwitchToAimState(Ped ped)
|
||||
{
|
||||
// can only switch to CrouchAim state
|
||||
if( ped.IsAimOn && ped.IsHoldingWeapon )
|
||||
if( ped.IsAimOn && ped.IsHoldingWeapon && BaseMovementState.EnoughTimePassedToSwitchToAimState(ped) )
|
||||
{
|
||||
ped.SwitchState<CrouchAimState>();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
public FocusPointParameters playerPedFocusPointParameters = new FocusPointParameters(false, 0f, 3f);
|
||||
public FocusPointParameters npcPedFocusPointParameters = FocusPointParameters.Default;
|
||||
|
||||
public float minTimeToReturnToAimState = 0.33f;
|
||||
|
||||
[Header("Camera")]
|
||||
|
||||
public float cameraDistanceFromPed = 3f;
|
||||
|
|
Loading…
Reference in a new issue