-
Notifications
You must be signed in to change notification settings - Fork 5
Path
Path represents a set of waypoints (Vector3D) to be consumed by PathFollowingBehavior or RandomWaypointBehavior. rewind parameter may be used to make the PathFollowingBehavior go back when the path is finished. For instance considering a path of following structure:
A -> B -> C
the movement if rewind is set to true would be:
A -> B -> C -> B -> A
loop parameter may be used to prevent a Path from finishing. Considering the same example path, the movement if loop is set to true would be (considering rewind parameter is false):
A -> B -> C -> A -> B -> C -> A -> B -> C ...
// create a Path
var path = new Kompute.Path();
// add waypoints
path.addWaypoint(new Kompute.Vector3D(100, 200, 300));
path.addWaypoint(new Kompute.Vector3D(300, 200, 300));
path.addWaypoint(new Kompute.Vector3D(500, 200, 300));Paths are designed to be consumed by a single steerable, that's why it is suggested not to share PathFollowingBehavior between multiple steerables. In order to use the same Path for multiple steerables, the path needs to be cloned first:
// clonedPath may be used by another PathFollowing or RandomWaypoint behavior
var clonedPath = path.clone();An instance of JumpDescriptor may be inserted into a Path in order to automatically trigger a jump while appliying PathFollowing or RandomWaypoint behaviors.
// create a Path
var path = new Kompute.Path();
// define waypoints
var wp1 = new Kompute.Vector3D(100, 200, 300);
var wp2 = new Kompute.Vector3D(300, 200, 300);
var wp3 = new Kompute.Vector3D(500, 200, 300);
// add waypoints
path.addWaypoint(wp1);
path.addWaypoint(wp2);
path.addWaypoint(wp3);
// create a JumpDescriptor from wp1 to wp2
var jumpDescriptor = new Kompute.JumpDescriptor({
takeoffPosition: wp1, landingPosition: wp2,
runupSatisfactionRadius: 100, takeoffPositionSatisfactionRadius: 100,
takeoffVelocitySatisfactionRadius: 100
});
// insert the JumpDescriptor into the Path
path.addJumpDescriptor(jumpDescriptor);addFinishCallback API may be used in order to listen for a path finish. This API returns a listener ID. This ID may later be passed to removeFinishCallback API stop listening for the finish.
// set the finish callback
var finishCallback = function(){
console.log("Path is finished.");
};
var listenerID = path.addFinishCallback(finishCallback);
// If necessary
// path.removeFinishCallback(listenerID);Paths may be visualised for debugging purposes via DebugHelper. See here.
AStar instances contain a path property which can be piped to PathFollowingBehavior. See here.
- Core
- Path
-
Steering Behaviors
- AlignBehavior
- ArriveBehavior
- AvoidBehavior
- BlendedSteeringBehavior
- CohesionBehavior
- EvadeBehavior
- FleeBehavior
- HideBehavior
- JumpBehavior
- LookWhereYouAreGoingBehavior
- PathFollowingBehavior
- PrioritySteeringBehavior
- PursueBehavior
- RandomPathBehavior
- RandomWaypointBehavior
- SeekBehavior
- SeparationBehavior
- Wander2DBehavior
- Wander3DBehavior
- Math
- Extra