예제 #1
0
 private void Start()
 {
     if (!EscapeGraph.Initialized)
     {
         EscapeGraph.InitializeExitGraph();
     }
 }
예제 #2
0
    private void Flee(AIStateController controller)
    {
        controller.Look();

        bool fallback = false;
        var  planner  = controller.GetComponent <EscapePlanner>();

        if (planner && EscapeGraph.Initialized)
        {
            //Vector3 prevDest = controller.navMeshAgent.destination;
            Vector3 dest = EscapeGraph.GetDestination(controller.transform.position, controller.transform.forward, controller.visibleTargets, planner.areaName);
            if (Vector3.SqrMagnitude(dest - controller.transform.position) > 1.0f)
            {
                controller.navMeshAgent.destination      = dest;
                controller.navMeshAgent.stoppingDistance = 1e-3f;
                controller.navMeshAgent.isStopped        = false; // is this safe?
            }
            else
            {
                fallback = true;
            }
        }
        else
        {
            fallback = true;
        }


        if (fallback)
        {
            Flee_DirectOpposite(controller);
        }
    }