void TryToChaseTarget() { if (animalHandler.MyChaseTransform != null && myNavMeshAgent != null && !animalHandler.isNavPaused) { myNavMeshAgent.SetDestination(animalHandler.MyChaseTransform.position); if (myNavMeshAgent.remainingDistance > myNavMeshAgent.stoppingDistance) { animalHandler.CallEventAnimalWalking(); animalHandler.isOnRoute = true; } } }
void CheckIfIShouldWander() { if (animalHandler.MyChaseTransform == null && !animalHandler.isOnRoute && !animalHandler.isNavPaused) { if (RandomWanderTarget(myTransform.position, wanderRange, out wanderTarget)) { animalHandler.state = AnimalState.WANDER; Debug.Log(this.gameObject.name + " is wandering"); myNavMeshAgent.SetDestination(wanderTarget); animalHandler.isOnRoute = true; animalHandler.CallEventAnimalWalking(); } } }
void CheckIfIShouldFlee() { if (isFleeing) { if (fleeTarget != null && !animalHandler.isOnRoute && !animalHandler.isNavPaused) { float distToTarget = Vector3.Distance(myTransform.position, fleeTarget.position); if (FleeTarget(out runPosition) && distToTarget < fleeRange) { Debug.Log("Flee destination set"); myNavMeshAgent.SetDestination(runPosition); animalHandler.CallEventAnimalWalking(); animalHandler.isOnRoute = true; } } } }