void checkForWanderAvail()
        {
            if (!enemyManagerMasterScript.isOnRoute && !enemyManagerMasterScript.isNavPaused)
            {
                if (enemyManagerMasterScript.enemyTarget == null)
                {
                    if (randomWanderTarget(myTransform.position, wanderRange, out wanderTarget))
                    {
                        myNavMeshAgent.SetDestination(wanderTarget);
                        enemyManagerMasterScript.isOnRoute = true;
                        enemyManagerMasterScript.callEnemyWalkingEvent();
                    }
                }

                else
                {
                    Vector3 toOther = enemyManagerMasterScript.enemyTarget.position - myTransform.position;
                    if (Vector3.Dot(toOther, myTransform.forward) < 0.98f)
                    {
                        if (randomWanderTarget(myTransform.position, wanderRange, out wanderTarget))
                        {
                            myNavMeshAgent.SetDestination(wanderTarget);
                            enemyManagerMasterScript.isOnRoute = true;
                            enemyManagerMasterScript.callEnemyWalkingEvent();
                        }
                    }
                }
            }
        }
        void tryToChaseTarget()
        {
            if (enemyManagerMasterScript.enemyTarget != null && myNavMeshAgent != null && !enemyManagerMasterScript.isNavPaused)
            {
                myNavMeshAgent.SetDestination(enemyManagerMasterScript.enemyTarget.position);

                if (myNavMeshAgent.remainingDistance > myNavMeshAgent.stoppingDistance)
                {
                    enemyManagerMasterScript.callEnemyWalkingEvent();
                    enemyManagerMasterScript.isOnRoute = true;
                }
            }
        }
示例#3
0
 void checkForFlee()
 {
     if (isFleeing)
     {
         if (fleeTarget != null && !enemyManagerMasterScript.isOnRoute && !enemyManagerMasterScript.isNavPaused)
         {
             if (directionToFlee(out runPosition) && Vector3.Distance(myTransform.position, fleeTarget.position) < fleeRange)
             {
                 myNavMeshAgent.SetDestination(runPosition);
                 enemyManagerMasterScript.callEnemyWalkingEvent();
                 enemyManagerMasterScript.isOnRoute = true;
             }
         }
     }
 }