From 197b0d58ff80275025990c411af450e4e5d8ed20 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 17 Oct 2021 19:36:15 +0200 Subject: [PATCH] dont quickly switch between drive-by and sitting states --- .../Scripts/Behaviours/Ped/States/DriveByState.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs b/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs index c1101f25..901269be 100644 --- a/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs @@ -47,7 +47,17 @@ namespace SanAndreasUnity.Behaviours.Peds.States } } + private float m_lastTimeWhenDeactivated = 0f; + public float timeUntilAbleToSwitchState = 0.3f; + + + + public override void OnBecameInactive() + { + m_lastTimeWhenDeactivated = Time.time; + base.OnBecameInactive(); + } protected override void EnterVehicleInternal() { @@ -65,6 +75,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States public bool CanEnterState(Vehicle vehicle, Vehicle.SeatAlignment seatAlignment) { + if (Time.time - m_lastTimeWhenDeactivated > this.timeUntilAbleToSwitchState) + return false; + var w = m_ped.CurrentWeapon; return null != w && w.IsGun; }