SteeringBehavior()

Base class for all concrete steering behaviors. They produce a force that describes where an agent should move and how fast it should travel to get there.

Note: All built-in steering behaviors assume a Vehicle#mass of one. Different values can lead to an unexpected results.

new SteeringBehavior()

Constructs a new steering behavior.

Author:

Members

active :Boolean

Whether this steering behavior is active or not.

Default Value:
  • true

weight :Number

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

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.

fromJSON(json) → {SteeringBehavior}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
SteeringBehavior -

A reference to this steering behavior.

resolveReferences(entities) → {SteeringBehavior}

Restores UUIDs with references to GameEntity objects.

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

Maps game entities to UUIDs.

Returns:
SteeringBehavior -

A reference to this steering behavior.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.