diff --git a/Assets/Scripts/Behaviours/Ped/States/BaseVehicleState.cs b/Assets/Scripts/Behaviours/Ped/States/BaseVehicleState.cs index 9e99d246..e0bb7517 100644 --- a/Assets/Scripts/Behaviours/Ped/States/BaseVehicleState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/BaseVehicleState.cs @@ -14,6 +14,17 @@ namespace SanAndreasUnity.Behaviours.Peds.States public Vehicle.SeatAlignment CurrentVehicleSeatAlignment { get { return this.CurrentVehicleSeat.Alignment; } } + protected void Cleanup() + { + if (!m_ped.IsInVehicle) + { + m_ped.characterController.enabled = true; + // restore seat's occupying ped ? - no + m_ped.transform.SetParent(null, true); + m_model.IsInVehicle = false; + } + } + protected override void UpdateHeading() { diff --git a/Assets/Scripts/Behaviours/Ped/States/VehicleEnteringState.cs b/Assets/Scripts/Behaviours/Ped/States/VehicleEnteringState.cs index 4f89404f..6abdcf39 100644 --- a/Assets/Scripts/Behaviours/Ped/States/VehicleEnteringState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/VehicleEnteringState.cs @@ -17,13 +17,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States { // restore everything - if (!m_ped.IsInVehicle) - { - m_ped.characterController.enabled = true; - // restore seat's occupying ped ? - no - m_ped.transform.SetParent(null, true); - m_model.IsInVehicle = false; - } + this.Cleanup(); if (m_coroutine != null) StopCoroutine(m_coroutine); diff --git a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs index a195a1da..9c6eb12e 100644 --- a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs @@ -12,7 +12,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States public override void OnBecameInactive() { - + this.Cleanup(); base.OnBecameInactive(); }