public Goal Suggest(KinematicData character, GlobalPath path, Goal goal) { Vector3 characterPoint = NavigationManager.Instance.NavMeshGraphs [0].ClosestPointOnGraph(character.position, aMaxYOffset); NavigationGraphNode characterNodeInGraph = NavigationManager.Instance.NavMeshGraphs [0].QuantizeToNode(characterPoint, 1.0f); Vector3 suggestedPoint = NavigationManager.Instance.NavMeshGraphs [0].ClosestPointOnGraph(suggestedPosition, aMaxYOffset); NavigationGraphNode nodeInGraph = NavigationManager.Instance.NavMeshGraphs [0].QuantizeToNode(suggestedPoint, 1.0f); Debug.DrawRay(characterPoint, (suggestedPoint - characterPoint), Color.cyan); Goal suggestedGoal = new Goal() { HasPosition = true, position = suggestedPoint, IsNew = true }; GlobalPath suggestedPath = new GlobalPath(); suggestedPath.PathPositions.Add(characterPoint); suggestedPath.PathPositions.Add(suggestedPoint); suggestedPath.PathNodes.Add(characterNodeInGraph); suggestedPath.PathNodes.Add(nodeInGraph); suggestedPath.CalculateLocalPathsFromPathPositions(characterPoint); suggestedGoal.Path = suggestedPath; forgive = true; return suggestedGoal; }
public GlobalPath GetPath(Movement.KinematicData character, Goal goal) { if (goal.HasPosition && goal.Path != null) { float actualTime = Time.realtimeSinceStartup; if (actualTime - previousSmooth > SecondsToSmooth || currentSmoothedSolution == null || goal.IsNew || goal != previousGoal) { previousSmooth = actualTime; currentSmoothedSolution = StringPullingPathSmoothing.SmoothPath(character, goal.Path); currentSmoothedSolution.CalculateLocalPathsFromPathPositions(character.position); } previousGoal = goal; return currentSmoothedSolution; } return null; }