예제 #1
0
 void MoveRandom(StateController controller)
 {
     // controller.ai.agent.isStopped = false;
     controller.ai.astarAgent.isStopped = false;
     if (!controller.movePositionSet)
     {
         // controller.ai.agent.SetDestination(AICharacter.RandomNavSphere(controller.ai.transform.position, controller.ai.wanderDistance));
         controller.ai.astarAgent.destination = AICharacter.RandomPointCircle(controller.ai.transform.position, controller.ai.wanderDistance);
         controller.movePositionSet           = true;
     }
 }
예제 #2
0
 void Wander(StateController controller)
 {
     controller.ai.astarAgent.isStopped = false;
     // Set a brand new move position at the beginning of the state
     if (!controller.movePositionSet)
     {
         // controller.ai.agent.SetDestination(AICharacter.RandomNavSphere(controller.ai.transform.position, controller.ai.wanderDistance));
         controller.ai.astarAgent.destination = AICharacter.RandomPointCircle(controller.ai.transform.position, controller.ai.wanderDistance);
         controller.movePositionSet           = true;
     }
     if (Vector3.Distance(controller.ai.transform.position, controller.ai.astarAgent.destination) <= controller.ai.richAgent.endReachedDistance + 1)
     {
         // controller.ai.agent.SetDestination(AICharacter.RandomNavSphere(controller.ai.transform.position, controller.ai.wanderDistance));
         controller.ai.astarAgent.destination = AICharacter.RandomPointCircle(controller.ai.transform.position, controller.ai.wanderDistance);
     }
 }
예제 #3
0
    void Chase(StateController controller)
    {
        controller.ai.astarAgent.isStopped = false;
        if (controller.target != null && !controller.movePositionSet)
        {
            Vector3[] path   = AICharacter.CalculatePath(controller.ai.seeker, controller.transform.position, controller.target.transform.position);
            Vector3   pointA = AICharacter.FindPointAlongPath(path, controller.ai.wanderDistance);
            Vector3   pointB = AICharacter.RandomPointCircle(pointA, controller.ai.wanderVariance);
            pointB = new Vector3(pointB.x, pointA.y, pointB.z); // Set pointB y equal to pointA y
            controller.ai.astarAgent.destination = pointB;
            controller.movePositionSet           = true;

            /*
             * NavMeshPath path = new NavMeshPath();
             * if (NavMesh.CalculatePath(controller.transform.position, controller.target.transform.position, NavMesh.AllAreas, path)) {
             *  Vector3 pointA = AICharacter.FindPointAlongPath(path.corners, controller.ai.wanderDistance);
             *  Vector3 pointB = AICharacter.RandomNavSphere(pointA, controller.ai.wanderVariance);
             *  pointB = new Vector3(pointB.x, pointA.y, pointB.z); // Set pointB y equal to pointA y
             *  controller.ai.astarAgent.destination = pointB;
             *  controller.movePositionSet = true;
             * }
             */
        }
    }
예제 #4
0
 public Vector3 RandomPoint(Vector3 origin, float distance)
 {
     return(AICharacter.RandomPointCircle(origin, distance));
 }