예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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;
                }
            }
        }
예제 #3
0
        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;
                    }
                }
            }
        }