private void ProcessMovement(float deltaTime) { float distanceFromRescueArea = Vector3.Distance(gameObject.transform.position, rescueArea.transform.position); if (distanceFromRescueArea <= triggeringDistanceFromRescueArea) { myNavMeshAgent.speed = runSpeed; myNavMeshAgent.TryToSetNewDestination(rescueArea.transform.position); } else { if (myPlayerState.isAlive) { myNavMeshAgent.speed = walkSpeed; myNavMeshAgent.TryToSetNewDestination(myPlayerState.gameObject.transform.position); } } }
private void FollowPatrolPoints() { if (patrolPoints.Length > 0) { myNavMeshAgent.speed = walkSpeed; myNavMeshAgent.TryToSetNewDestination(patrolPoints [patrolPointIndex].transform.position); if (!myNavMeshAgent.pathPending) { if (myNavMeshAgent.remainingDistance < myNavMeshAgent.stoppingDistance) { patrolPointIndex++; if (patrolPointIndex >= patrolPoints.Length) { patrolPointIndex = 0; } } } } }