Skip to content

SeparationBehavior

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

Definition

SeparationBehavior iterates through all the nearby steerables for given steerable and produces a linear acceleration repelling from them. The strength parameter decides the strength of the repelling force.

Usage

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

// create a World
var world = new Kompute.World(1000, 1000, 1000, 50);

// insert steerables into the world
world.insertEntity(steerable);
world.insertEntity(steerable2);

// create an instance of Separation behavior
var separationBehavior = new Kompute.SeparationBehavior({ strength: 50 });

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