public SteeringPipeline InitializeSteeringPipeline(DynamicCharacter orig, KinematicData dest) { //Pipeline SteeringPipeline pipe = new SteeringPipeline(orig.KinematicData) { MaxAcceleration = 15.0f }; //Targeter Targeter MouseClickTargeter = new Targeter() { Target = dest }; pipe.Targeters.Add(MouseClickTargeter); //Decomposer pathfindingDecomposer = new PathfindingDecomposer() { Graph = this.navMesh, Heuristic = new EuclideanDistanceHeuristic() }; pipe.Decomposers.Add(pathfindingDecomposer); //Actuator - Default: Car behaviour Actuator actuator = new CarActuator() { MaxAcceleration = 15.0f, Character = orig.KinematicData }; if (orig.GameObject.tag.Equals("Enemies")) { actuator = new TrollActuator() { MaxAcceleration = 10.0f, Character = orig.KinematicData }; } pipe.Actuator = actuator; //Constraints foreach (DynamicCharacter troll in enemies) { TrollConstraint trollConstraint = new TrollConstraint() { Troll = troll, margin = 1.0f }; pipe.Constraints.Add(trollConstraint); } MapConstraint mapConstraint = new MapConstraint() { chars = character, navMeshP = navMesh, margin = 1.0f }; pipe.Constraints.Add(mapConstraint); return(pipe); }
public SteeringPipeline InitializeSteeringPipeline(DynamicCharacter orig) { //Pipeline SteeringPipeline pipe = new SteeringPipeline(orig.KinematicData) { MaxAcceleration = 15.0f }; //Targeter this.Targeter = new FixedTargeter(); pipe.Targeters.Add(this.Targeter); //Decomposer pathfindingDecomposer = new PathfindingDecomposer() { Graph = this.navMesh, Heuristic = new EuclideanDistanceHeuristic() }; pipe.Decomposers.Add(pathfindingDecomposer); //Actuator - Default: Car behaviour Actuator actuator = new CarActuator() { MaxAcceleration = 15.0f, Character = orig.KinematicData }; pipe.Actuator = actuator; /* if (orig.GameObject.tag.Equals("Enemies")) { actuator = new TrollActuator() { MaxAcceleration = 10.0f, Character = orig.KinematicData }; } pipe.Actuator = actuator; */ return pipe; }
public void OnDrawGizmos() { if (this.draw) { //draw the current Solution Path if any (for debug purposes) if (this.currentSolution != null) { Vector3 previousPosition = this.startPosition; foreach (Vector3 pathPosition in this.currentSolution.PathPositions) { Debug.DrawLine(previousPosition, pathPosition, Color.red); previousPosition = pathPosition; } previousPosition = this.character.KinematicData.position; if (this.currentSmoothedSolution != null) { Gizmos.color = Color.black; foreach (Vector3 pathPosition in this.currentSmoothedSolution.PathPositions) { Debug.DrawLine(previousPosition, pathPosition, Color.green); Gizmos.DrawCube(pathPosition, new Vector3(1f, 1f, 1f)); previousPosition = pathPosition; } } } // draw the nodes in Open and Closed Sets if (DecomposerComponent.aStarPathFinding != null) { Gizmos.color = Color.cyan; if (DecomposerComponent.aStarPathFinding.Open != null) { foreach (NodeRecord nodeRecord in DecomposerComponent.aStarPathFinding.Open.All()) { //Gizmos.DrawSphere(nodeRecord.node.LocalPosition, 1.0f); } } Gizmos.color = Color.blue; if (DecomposerComponent.aStarPathFinding.Closed != null) { foreach (NodeRecord nodeRecord in DecomposerComponent.aStarPathFinding.Closed.All()) { //Gizmos.DrawSphere(nodeRecord.node.LocalPosition, 1.0f); } } } Gizmos.color = Color.yellow; //draw the target for the follow path movement //GetMovement should only be used for debug purposes if (Actuator.GetMovement() != null) { Gizmos.DrawSphere(Actuator.GetMovement().Target.position, 1.0f); } if (this.currentSmoothedSolution != null && CharacterInUse == CharacterType.Car) { CarActuator carActuator = (CarActuator)Actuator; Gizmos.color = Color.green; if (carActuator.FollowPathMovement.Target != null) { Gizmos.DrawCube(carActuator.FollowPathMovement.Target.position, new Vector3(2f, 2f, 2f)); } Gizmos.color = Color.red; if (carActuator.SeekMovement.Target != null) { Gizmos.DrawCube(carActuator.SeekMovement.Target.position, new Vector3(2f, 2f, 2f)); } } } }