Skip to content

RandomWaypointBehavior

Oğuz Eroğlu edited this page Jun 11, 2020 · 1 revision

Definition

RandomWaypointBehavior chooses a random waypoint from a path and makes a steerable seek towards there. When the distance between the steerable and the current waypoint is less than satisfactionRadius , RandomWaypointBehavior chooses another random waypoint to seek towards.

Usage

// create a Steerable
var steerable = new Kompute.Steerable("steerable1", new Kompute.Vector3D(), new Kompute.Vector3D(10, 10, 10));

// set max speed and acceleration of the Steerable
steerable.maxSpeed = 100;
steerable.maxAcceleration = 100;

// Create a Path
var path = new Kompute.Path();

path.addWaypoint(new Kompute.Vector3D(0, 0, 0));
path.addWaypoint(new Kompute.Vector3D(100, 200, 300));

// Create an instance of RandomWaypointBehavior
var randomWaypointBehavior = new Kompute.RandomWaypointBehavior({ path: path, satisfactionRadius: 50 });

// set the behavior
steerable.setBehavior(randomWaypointBehavior);