-
Notifications
You must be signed in to change notification settings - Fork 5
AvoidBehavior
Oğuz Eroğlu edited this page Aug 19, 2020
·
6 revisions
This demo uses AvoidBehavior combined with SeekBehavior when the bots are switched to shooting mode.
AvoidBehavior makes a steerable avoid other entities and steerables lying in its path. The steerable does not try to avoid entities that are more than maxSeeAhead units away. When a threatening entity is detected, the steerable is accelerated maxAvoidForce units away from the threatening entity.
// create a steerable
var steerable = new Kompute.Steerable("steerable1", new Kompute.Vector3D(), new Kompute.Vector3D(10, 10, 10));
// create an obstacle
var obstacle = new Kompute.Entity("entity1", new Kompute.Vector3D(0, 0, 20), new Kompute.Vector3D(10, 10, 10));
// create a world
var world = new Kompute.World(1000, 1000, 1000, 50);
// insert entities to world
world.insertEntity(steerable);
world.insertEntity(obstacle);
// set max speed and acceleration of the steerable
steerable.maxSpeed = 100;
steerable.maxAcceleration = 100;
// create an instance of AvoidBehavior
var avoidBehavior = new Kompute.AvoidBehavior({ maxSeeAhead: 500, maxAvoidForce: 100 });
// set the behavior
steerable.setBehavior(avoidBehavior);- 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