public override void Update() { if (ParentAI.Target == null) { ParentAI.ClearActions(new AILookForPlayer()); ParentAI.AddAction(new AIWander()); End(); return; } if (Time.time - lastSync > 2) { float distance = Helper.DistanceFloatFromTarget(ParentAI.Target.transform.position, ParentAI.transform.position); if (distance < ParentAI.Attack.Range) { ParentAI.AddAction(new AIAttack()); } else if (distance < ParentAI.VisionRange) { ParentAI.Speed = ParentAI.BaseSpeed * 3.3f; ParentAI.Move(ParentAI.Target.transform.position); } else { ParentAI.AddAction(new AILookForPlayer()); ParentAI.AddAction(new AIWander()); ParentAI.Target = null; End(); } lastSync = Time.time; } }
public override void Update() { if (ParentAI.Target == null) { ParentAI.ClearActions(new AILookForPlayer()); ParentAI.AddAction(new AIWander()); End(); return; } else { ParentAI.Stop(ParentAI.Attack.Attack(ParentAI.Target)); End(); } }