private void Start() { if (!EscapeGraph.Initialized) { EscapeGraph.InitializeExitGraph(); } }
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); } }