-
Notifications
You must be signed in to change notification settings - Fork 5
CohesionBehavior
Oğuz Eroğlu edited this page Jun 13, 2020
·
1 revision
CohesionBehavior calculates the center position of each nearby steerable for given steerable, then makes the steerable seek towards that position. Use this behavior to keep a group of steerables together.
// 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));
var steerable3 = new Kompute.Steerable("steerable3", new Kompute.Vector3D(30, 20, 100), new Kompute.Vector3D(10, 10, 10));
// create a World
var world = new Kompute.World(1000, 1000, 1000, 500);
// insert steerables into the world
world.insertEntity(steerable);
world.insertEntity(steerable2);
world.insertEntity(steerable3);
// set the max acceleration and speed of the steerable
steerable.maxSpeed = 100;
steerable.maxAcceleration = 50;
// create an instance of CohesionBehavior
var cohesionBehavior = new Kompute.CohesionBehavior();
// set the behavior
steerable.setBehavior(cohesionBehavior);- 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