Exemplo n.º 1
0
    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;
            }
        }
    }
Exemplo n.º 2
0
    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();
            }
        }
    }
Exemplo n.º 3
0
 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;
             }
         }
     }
 }