‹›
Character

Moving Platforms

Follows translating or rotating bodies and optionally makes their local +Z the character's up direction.

Normal ground velocity is already used when a grounded character stands on a moving body. set_reference_frame() adds explicit transform following for rotating frames, vehicles, ships, or local-gravity environments.

Ordinary platform motion#

On walkable ground, the controller starts its velocity from get_ground_velocity(). A translating dynamic or kinematic platform therefore carries the character without requiring a reference frame.

Rotating reference frame#

GML
player.set_reference_frame(platform_body, false);

// Movement input is rotated with the platform.
player.set_move(input_x, input_y);
jolt_update();
  • The character position and rotation follow the body's center-of-mass transform delta.
  • The current up vector follows the body's local +Z axis.
  • Existing character velocity is rotated with the frame.
  • Frame linear and angular velocity are removed from the relative contact solve to avoid applying the motion twice.

Local gravity#

GML
player.set_reference_frame(planet_body, true);
player.set_reference_frame_gravity(true);

var up = player.get_up();

With reference-frame gravity enabled, gravity acts opposite the character's current up vector. Otherwise gravity remains global -Z even though movement is rotated by the frame.

Frame information#

GML
var platform = player.get_reference_frame();
var linear = player.get_reference_frame_velocity();
var angular = player.get_reference_frame_angular_velocity();
var desired = player.get_world_move_velocity();

Leaving the frame#

GML
player.clear_reference_frame();

Clearing restores +Z as up, rotates the character back into the world-up orientation, clears cached frame motion, and disables local-gravity mode.

Read the gravity mode#

GML
var uses_local_gravity = player.get_reference_frame_gravity();

get_reference_frame_gravity() reads whether gravity follows the frame's local up direction. It does not return an acceleration vector. For magnitude use get_gravity(); for current orientation use get_up().

Verified operation contracts#

These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.

Symbol / ownerSignatureOperation contract
JoltCharacter.clear_reference_frameJoltCharacter.clear_reference_frame()Boolean; clears the frame and restores +Z up, clears transport/external impulse state, does not destroy the host.
JoltCharacter.get_reference_frameJoltCharacter.get_reference_frame()Stored live JoltBody or undefined; not owned by the Character.
JoltCharacter.get_reference_frame_angular_velocityJoltCharacter.get_reference_frame_angular_velocity()Reference-frame angular velocity: world {x, y, z}, rad/s; undefined on error. Read support data together with ground_state.
JoltCharacter.get_reference_frame_gravityJoltCharacter.get_reference_frame_gravity()Boolean setting for frame-relative gravity. Setter Boolean success, getter Boolean state, also false on error.
JoltCharacter.get_reference_frame_velocityJoltCharacter.get_reference_frame_velocity()Reference-frame velocity: world {x, y, z}, m/s; undefined on error. Read support data together with ground_state.
JoltCharacter.get_upJoltCharacter.get_up()Up direction: world {x, y, z}, jednotkový vektor / unit vector; undefined on error. Read support data together with ground_state.
JoltCharacter.get_world_move_velocityJoltCharacter.get_world_move_velocity()Desired world movement: world {x, y, z}, m/s; undefined on error. Read support data together with ground_state.
JoltCharacter.set_reference_frameJoltCharacter.set_reference_frame(body, local_gravity = false)Live JoltBody in the same world, local_gravity=false by default. Boolean; rejected while attached. Transports reference-body motion, not attachment to a fixed local position.
JoltCharacter.set_reference_frame_gravityJoltCharacter.set_reference_frame_gravity(enabled)Boolean setting for frame-relative gravity. Setter Boolean success, getter Boolean state, also false on error.