OffsetPursuitBehavior(leader, offset)

This steering behavior produces a force that keeps a vehicle at a specified offset from a leader vehicle. Useful for creating formations.

new OffsetPursuitBehavior(leader, offset)

Constructs a new offset pursuit behavior.

Parameters:
Name Type Default Description
leader Vehicle null

The leader vehicle.

offset Vector3

The offset from the leader.

Author:

Extends

Members

active :Boolean

Whether this steering behavior is active or not.

Overrides:
Default Value:
  • true

nullable leader :Vehicle

The leader vehicle.

Default Value:
  • null

offset :Vector3

The offset from the leader.

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) → {OffsetPursuitBehavior}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
OffsetPursuitBehavior -

A reference to this behavior.

Overrides:

resolveReferences(entities) → {OffsetPursuitBehavior}

Restores UUIDs with references to GameEntity objects.

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

Maps game entities to UUIDs.

Returns:
OffsetPursuitBehavior -

A reference to this behavior.

Overrides:

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.

Overrides: