Skip to content

Wander3DBehavior

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

Definition

Wander3DBehavior behaves the same way as Wander2DBehavior without limiting the movement to a plane. It makes a steerable wander around in a 3D space. A whale moving freely in the ocean demonstrates this kind of behavior.

This behavior expects wanderSphereDistance and wanderSphereRadius parameters instead of wanderCircleDistance and wanderCircleRadius parameters of Wander2DBehavior.

Usage

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

// set the velocity of the steerable (this is not necessary if the steerable has another behaviors)
steerable.velocity.set(-1000, 230, 500);

// create an instance of Wander3DBehavior
var wanderBehavior = new Kompute.Wander3DBehavior({
  angleChange: Math.PI / 100,
  wanderSphereDistance: 100,
  wanderSphereRadius: 50
});

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