ObstacleAvoidanceBehavior(obstacles)

This steering behavior produces a force so a vehicle avoids obstacles lying in its path.

new ObstacleAvoidanceBehavior(obstacles)

Constructs a new obstacle avoidance behavior.

Parameters:
Name Type Description
obstacles Array.<GameEntity>

An Array with obstacle of type GameEntity.

Author:

Extends

Members

active :Boolean

Whether this steering behavior is active or not.

Overrides:
Default Value:
  • true

brakingWeight :Number

This factor determines how much the vehicle decelerates if an intersection occurs.

Default Value:
  • 0.2

dBoxMinLength :Number

Minimum length of the detection box used for intersection tests.

Default Value:
  • 4

obstacles :Array.<GameEntity>

An Array with obstacle of type GameEntity.

weight :Number

Can be used to tweak the amount that a steering force contributes to the total steering force.

Overrides:
Default Value:
  • 1

Methods

calculate(vehicle, force, delta) → {Vector3}

Calculates the steering force for a single simulation step.

Parameters:
Name Type Description
vehicle Vehicle

The game entity the force is produced for.

force Vector3

The force/result vector.

delta Number

The time delta.

Returns:
Vector3 -

The force/result vector.

Overrides:

fromJSON(json) → {ObstacleAvoidanceBehavior}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
ObstacleAvoidanceBehavior -

A reference to this behavior.

Overrides:

resolveReferences(entities) → {ObstacleAvoidanceBehavior}

Restores UUIDs with references to GameEntity objects.

Parameters:
Name Type Description
entities Map.<String, GameEntity>

Maps game entities to UUIDs.

Returns:
ObstacleAvoidanceBehavior -

A reference to this behavior.

Overrides:

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.

Overrides: