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#
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#
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#
rail.enable_motor(false);
rail.enable_motor(true);
var state = rail.get_motor_state();| State field | Meaning |
|---|---|
| enabled | Whether the native motor is active. |
| mode | JOLT_MOTOR_OFF, VELOCITY, or POSITION. |
| target_velocity | Current velocity target. |
| target_position | Current distance target. |
| max_force | Symmetric force limit. |
| spring_frequency / spring_damping | Position motor response. |
Monitoring#
var distance = rail.get_path_distance();
var speed = rail.get_speed();
var motor_impulse = rail.get_impulse();