From 51545ef571ce57ccdd2d2538c8c66a92909bad50 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sat, 16 Oct 2021 22:06:54 +0200 Subject: [PATCH] exit Chase state if there is no weapon or no ammo --- Assets/Scripts/Behaviours/PedAI/ChaseState.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/Scripts/Behaviours/PedAI/ChaseState.cs b/Assets/Scripts/Behaviours/PedAI/ChaseState.cs index 85f2560a..69882065 100644 --- a/Assets/Scripts/Behaviours/PedAI/ChaseState.cs +++ b/Assets/Scripts/Behaviours/PedAI/ChaseState.cs @@ -37,6 +37,13 @@ namespace SanAndreasUnity.Behaviours.Peds.AI { this.ChooseBestWeapon(); + if (null == _ped.CurrentWeapon) + { + // we have no weapon to attack with, or no ammo + _pedAI.StartWalkingAround(); + return; + } + if (null == this.TargetPed) { this.TargetPed = this.GetNextPedToAttack();