private static void SetDestinationIfIsCloser(NavTilemapAgent agent, Vector3 attractorPosition) { if (!IsCloser(agent, attractorPosition)) { return; } agent.destination = attractorPosition; if (s_IsVerbose) { DebugUtil.Log("TriggerNavTargetSystem.SetDestinationIfIsCloser: agent=" + agent + " attractorPosition=" + attractorPosition); } }
private static bool IsCloser(NavTilemapAgent agent, Vector3 attractorPosition) { var pathToAttractor = agent.GetPath(attractorPosition); if (pathToAttractor == null) { return(false); } if (agent.hasPath) { int attractorDistance = NavTilemapAgent.GetNumSteps(pathToAttractor); if (attractorDistance >= agent.pathDistance) { return(false); } } return(true); }