-
Notifications
You must be signed in to change notification settings - Fork 5
HideBehavior
Oğuz Eroğlu edited this page Aug 9, 2020
·
6 revisions
Available here.
HideBehavior always tries to put an obstacle between the steerable and the entity it's hiding from. This behavior requests acceleartion if the target entity is up to threatDistance units away from the steerable. It then tries to find the closest obstacle and hides behind it, staying hideDistance units away from the obstacle.
Once the hiding position is calculated, this behavior works the same way as ArriveBehavior to make the steerable arrive there. That's why satisfactionRadius and slowDownRadius parameters are also configured to create this behavior.
// create the steerable
var steerable = new Kompute.Steerable("steerable1", new Kompute.Vector3D(), new Kompute.Vector3D(10, 10, 10));
// create an obstacle
var obstacle = new Kompute.Entity("obstacle1", new Kompute.Vector3D(30, 30, 30), new Kompute.Vector3D(10, 10, 10));
// create another steerable to hide from
var hideTarget = new Kompute.Steerable("steerable2", new Kompute.Vector3D(), new Kompute.Vector3D(10, 10, 10));
// create a world
var world = new Kompute.World(1000, 1000, 1000, 50);
// insert entities
world.insertEntity(steerable);
world.insertEntity(obstacle);
world.insertEntity(hideTarget);
// set max speed and acceleration of the steerable
steerable.maxSpeed = 100;
steerable.maxAcceleration = 100;
// set target entity to hide from
steerable.setHideTargetEntity(hideTarget);
// create an instance of HideBehavior
var hideBehavior = new Kompute.HideBehavior({
arriveSatisfactionRadius: 50,
arriveSlowDownRadius: 100,
hideDistance: 150,
threatDistance: 2000
});
// set behavior
steerable.setBehavior(hideBehavior);excludeFromHide flag may be used on entities in order to exclude such entities from HideBehavior. This flag signals HideBehavior to not to hide behind this entity.
entity.excludeFromHide = true; // steerable won't hide behind this entity- 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