Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private FindPathToTarget _findPathToTarget;
- _findPathToTarget = new FindPathToTarget();
- _findPathToTarget.maxIterationsPerFrame = maxPathFindStepsPerFrame;
- public bool GetPathToMoveTarget(Agent agent, float deltaTime, out PathBase path)
- {
- bool stillWorking = false;
- path = null;
- if (_findPathToTarget.inProgress)
- {
- stillWorking = (_findPathToTarget.Execute(agent, deltaTime) == Action.Action.ActionResult.RUNNING);
- }
- else
- {
- _findPathToTarget.SetActionContext(agent.actionContext);
- if (_currentPathGraph is NavGridMultiRegionGraph) ((NavGridMultiRegionGraph)_currentPathGraph).stepUpHeight = agent.Kinematic.StepUpHeight;
- _findPathToTarget.pathGraph = _currentPathGraph;
- _findPathToTarget.pathTarget = moveTarget.GetMoveTarget(deltaTime);
- _findPathToTarget.Start(agent, deltaTime);
- stillWorking = (_findPathToTarget.Execute(agent, deltaTime) == Action.Action.ActionResult.RUNNING);
- }
- if (!stillWorking)
- {
- _findPathToTarget.Stop(agent, deltaTime);
- }
- path = agent.actionContext.GetContextItem<PathBase>(PathConstants.PATHTOTARGET);
- return !stillWorking;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement