public Decomposer(SteeringPipeline pipeline, NavMeshPathGraph navMesh, DynamicCharacter character) { Character = character; Pipeline = pipeline; aStarPathFinding = new NodeArrayAStarPathFinding(navMesh, new EuclideanDistanceHeuristic()); aStarPathFinding.NodesPerSearch = 150; }
public override TargetGoal Decompose(KinematicData character, TargetGoal goal) { if (!goal.hasPosition) return new TargetGoal(); if (lastGoal == null || !lastGoal.position.Equals(goal.position)) { Astar = new NodeArrayAStarPathFinding(Graph, Heuristic); Astar.InitializePathfindingSearch(character.position, goal.position); CurrentParam = 0.0f; this.lastGoal = goal; } GlobalPath currentSolution; if (Astar.InProgress) { var finished = Astar.Search(out currentSolution, true); if (finished && currentSolution != null) { this.AStarSolution = currentSolution; this.GlobalPath = StringPullingPathSmoothing.SmoothPath(character, currentSolution); this.GlobalPath.CalculateLocalPathsFromPathPositions(character.position); // gets first node goal.position = this.GlobalPath.LocalPaths[0].EndPosition; return goal; } /* else if(currentSolution != null && currentSolution.IsPartial) { goal.position = currentSolution.PathPositions[0]; return goal; }*/ } else { if (GlobalPath.PathEnd(CurrentParam)) { goal.position = GlobalPath.LocalPaths[GlobalPath.LocalPaths.Count - 1].GetPosition(1.0f); return goal; } CurrentParam = GlobalPath.GetParam(character.position, CurrentParam); CurrentParam += GlobalPath.CalculateOffset(CurrentParam); goal.position = GlobalPath.GetPosition(CurrentParam); return goal; } return new TargetGoal(); }
// Use this for initialization void Awake () { this.draw = false; this.currentClickNumber = 1; this.navMesh = NavigationManager.Instance.NavMeshGraphs [0]; BoundingBox mapSize = new BoundingBox(); mapSize.minX = -200; mapSize.minZ = -200; mapSize.maxX = 200; mapSize.maxZ = 200; this.goalbounding = new GoalBounding(navMesh, mapSize); this.aStarPathFinding = new NodeArrayAStarPathFinding(this.navMesh,new SimpleHeuristic(),true); this.aStarPathFinding.NodesPerSearch = 100; }
public override Goal Decompose(KinematicData character, Goal goal) { AStarPathfinding Astar = new NodeArrayAStarPathFinding(Graph, Heuristic); Astar.InitializePathfindingSearch(character.position, goal.position); // In goal, ends if (Astar.StartNode.Equals(Astar.GoalNode)) { return goal; } // else, plan GlobalPath currentSolution; if (Astar.InProgress) { var finished = Astar.Search(out currentSolution, true); if (finished && currentSolution != null) { // gets first node goal.position = currentSolution.PathNodes[0].Position; return goal; } } return goal; }
public Decomposer(NodeArrayAStarPathFinding algorithm) { this.searchAlgorithm = algorithm; }