Paths

Path Motors

Drives a constrained body by target velocity or target distance along the path.

Path motors share the managed JoltConstraint motor interface. Setting a target automatically selects and enables the corresponding motor mode and activates the connected body or bodies.

Velocity motor#

GML
rail.set_motor_max_force(500);
rail.set_motor_velocity(4);

The target velocity is measured in path-distance units per second. Positive and negative values move in opposite directions along the curve.

Position motor#

GML
rail.set_motor_spring(2, 1);
rail.set_motor_max_force(300);
rail.set_motor_position(12);

The target is a distance along the path, not a normalized fraction. It is converted to the native Hermite fraction through the path's arc-length table.

Motor controls#

GML
rail.enable_motor(false);
rail.enable_motor(true);

var state = rail.get_motor_state();
State fieldMeaning
enabledWhether the native motor is active.
modeJOLT_MOTOR_OFF, VELOCITY, or POSITION.
target_velocityCurrent velocity target.
target_positionCurrent distance target.
max_forceSymmetric force limit.
spring_frequency / spring_dampingPosition motor response.

Monitoring#

GML
var distance = rail.get_path_distance();
var speed = rail.get_speed();
var motor_impulse = rail.get_impulse();