mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
smooth out switching from aim to non-aim states
This commit is contained in:
parent
d62eb43c78
commit
0214244ee3
4 changed files with 16 additions and 2 deletions
|
@ -167,6 +167,7 @@ MonoBehaviour:
|
|||
revealRadius: 150
|
||||
timeToKeepRevealingAfterRemoved: 3
|
||||
minTimeToReturnToAimState: 0.33
|
||||
minTimeToReturnToNonAimStateFromAimState: 0.33
|
||||
cameraDistanceFromPed: 5
|
||||
minCameraDistanceFromPed: 2
|
||||
maxCameraDistanceFromPed: 30
|
||||
|
|
|
@ -61,7 +61,18 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
{
|
||||
// check if we should exit aiming state
|
||||
|
||||
if (!m_ped.IsHoldingWeapon || !m_ped.IsAimOn)
|
||||
|
||||
if (null == m_weapon)
|
||||
{
|
||||
BaseMovementState.SwitchToMovementStateBasedOnInput(m_ped);
|
||||
return true;
|
||||
}
|
||||
|
||||
// wait until we start pointing gun - this is used to prevent fast state switching
|
||||
if (this.TimeSinceActivated < Mathf.Max(this.AimAnimMaxTime, PedManager.Instance.minTimeToReturnToNonAimStateFromAimState))
|
||||
return false;
|
||||
|
||||
if (!m_ped.IsAimOn)
|
||||
{
|
||||
BaseMovementState.SwitchToMovementStateBasedOnInput (m_ped);
|
||||
return true;
|
||||
|
@ -69,7 +80,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
if (m_ped.IsSprintOn)
|
||||
{
|
||||
if (null == m_weapon || m_weapon.CanSprintWithIt)
|
||||
if (m_weapon.CanSprintWithIt)
|
||||
{
|
||||
m_ped.SwitchState<SprintState>();
|
||||
return true;
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
protected bool m_shouldSendButtonEvents { get { return !m_isServer && m_ped.IsControlledByLocalPlayer; } }
|
||||
|
||||
public float LastTimeWhenActivated { get; set; } = 0f;
|
||||
public float TimeSinceActivated => Time.time - this.LastTimeWhenActivated;
|
||||
public float LastTimeWhenDeactivated { get; set; } = 0f;
|
||||
public float TimeSinceDeactivated => Time.time - this.LastTimeWhenDeactivated;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public FocusPointParameters npcPedFocusPointParameters = FocusPointParameters.Default;
|
||||
|
||||
public float minTimeToReturnToAimState = 0.33f;
|
||||
public float minTimeToReturnToNonAimStateFromAimState = 0.33f;
|
||||
|
||||
[Header("Camera")]
|
||||
|
||||
|
|
Loading…
Reference in a new issue