void CheckIfIShouldWander() { if (enemyMaster.myTarget == null && !enemyMaster.isOnRoute && !enemyMaster.isNavPaused) { if (RandomWanderTarget(myTransform.position, wanderRange, out wanderTarget)) { myNavMeshAgent.SetDestination(wanderTarget); enemyMaster.isOnRoute = true; enemyMaster.CallEventEnemyWalking(); } } }
void TryToChaseTarget() { if (enemyMaster.myTarget != null && myNavMeshAgent != null && !enemyMaster.isNavPaused) { myNavMeshAgent.SetDestination(enemyMaster.myTarget.position); if (myNavMeshAgent.remainingDistance > myNavMeshAgent.stoppingDistance) { enemyMaster.CallEventEnemyWalking(); enemyMaster.isOnRoute = true; } } }
void CheckIfIShouldFlee() { if (isFleeing == true) { if (fleeTarget != null && !enemyMaster.isOnRoute && !enemyMaster.isNavPaused) { float distanceOf = Vector3.Distance(myTransform.position, fleeTarget.position); if (FleeTarget(out runPosition) && distanceOf < fleeRange) { myNavMeshAgent.SetDestination(runPosition); enemyMaster.CallEventEnemyWalking(); enemyMaster.isOnRoute = true; } } } }