OnPathBehavior(path, radius, predictionFactor)

This steering behavior produces a force that keeps a vehicle close to its path. It is intended to use it in combination with FollowPathBehavior in order to realize a more strict path following.

new OnPathBehavior(path, radius, predictionFactor)

Constructs a new on path behavior.

Parameters:
Name Type Default Description
path Path

The path to stay close to.

radius Number 0.1

Defines the width of the path. With a smaller radius, the vehicle will have to follow the path more closely.

predictionFactor Number 1

Determines how far the behavior predicts the movement of the vehicle.

Author:

Extends

Members

active :Boolean

Whether this steering behavior is active or not.

Overrides:
Default Value:
  • true

path :Path

The path to stay close to.

predictionFactor :Number

Determines how far the behavior predicts the movement of the vehicle.

Default Value:
  • 1

radius :Number

Defines the width of the path. With a smaller radius, the vehicle will have to follow the path more closely.

Default Value:
  • 0.1

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

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
OnPathBehavior -

A reference to this behavior.

Overrides:

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.

Overrides:

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.

Overrides: