‹›
Utility Scripts

Conveyor Belts

Turns the upper surface of an existing body into a moving physical contact surface.

jolt_conveyor attaches a managed native helper to one non-sensor Static or Kinematic JoltBody. Dynamic cargo is transported by Jolt's contact solver and friction: its position, rotation and velocity are never teleported, and ordinary collisions remain active.

Syntax#

Syntax
jolt_conveyor(body, options=undefined)

Arguments#

ArgumentTypeDescription
bodyJoltBodyA live, non-sensor Static or Kinematic host in the managed default world.
optionsStruct or undefinedOptional surface direction, speed, layer and smart-assistance settings.

Options#

FieldDefaultDescription
direction{x:0,y:1,z:0}Non-zero movement direction, projected onto the host's upper tangent plane.
speed1.0Target contact-surface speed in world units per second; may be zero or negative.
spaceJOLT_CONVEYOR_LOCALLOCAL follows host rotation; WORLD keeps the direction absolute in world space.
layersundefinedEligible cargo JoltLayer, layer array or numeric mask.
center_objectsfalseApplies a physical lateral correction toward the belt centre axis.
center_strength100.0Positive maximum centering force and PD stiffness.
align_rotationfalsePhysically aligns cargo yaw to discrete angles relative to the host.
rotation_step90.0Alignment interval in degrees; valid range is greater than 0 and at most 360.
rotation_strength50.0Positive maximum alignment torque and PD stiffness.

Public methods#

MethodPurpose
is_valid() / destroy()Checks or removes the helper without destroying its host body.
get_native_handle()Returns the opaque native helper handle, or 0 when invalid.
set_speed(speed) / get_speed()Changes, reverses or stops the surface at runtime.
set_direction(x,y,z) / get_direction()Changes or reads the stored non-zero direction.
set_centering(enabled,strength)Enables or updates physical lateral centering.
set_rotation_alignment(enabled,step,strength)Enables or updates physical yaw alignment.
set_layers(layers)Changes the cargo layer filter without modifying the global collision matrix.

Contact and movement rules#

  • Only Dynamic, non-sensor rigid bodies in real upper-surface contact are transported. Airborne, side-contact and underside bodies are ignored.
  • The top test uses the host's local +Z normal and accepts contact normals inside a 60-degree top cone.
  • Speed is a target relative surface velocity, not an impulse accumulated every Step. Friction, normal force, cargo mass and contact conditions determine the actual response.
  • Boxes translate while spheres and cylinders can roll naturally. Cargo-to-cargo collision and all normal contact response remain active.
  • LOCAL direction follows rotated or inclined hosts. WORLD stays absolute, but is still projected onto the upper tangent plane and cannot create lift.
  • Changing speed, direction, layers or smart assistance wakes eligible bodies touching the real host shape.

Centering and rotation alignment#

  • Centering applies a capped lateral PD force toward the line through the public host origin in the conveyor direction. It has no forward component and never teleports cargo.
  • Rotation alignment applies capped torque around the surface normal toward the nearest rotation_step multiple relative to the host orientation.
  • Alignment controls projected yaw only; it is not full three-dimensional upright stabilization.
  • Both smart helpers operate only during top contact and can be resisted by mass, friction and other colliders.

Example#

GML
var conveyor_body = jolt_box_create_static(0, 0, 0, 3, 20, 0.5, {
    friction: 0.8
});

var belt = jolt_conveyor(conveyor_body, {
    direction: {x:0, y:1, z:0},
    speed: 2,
    center_objects: true,
    center_strength: 100,
    align_rotation: true,
    rotation_step: 90,
    rotation_strength: 50
});

Runtime control#

GML
belt.set_speed(-2); // Reverse
belt.set_speed(0);  // Stop physical surface motion

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
jolt_conveyorjolt_conveyor(body = undefined, options = undefined)Creates a JoltConveyor in a running managed world, otherwise undefined. Without a body this is a pending helper: setters work, is_valid remains false until set_body. Defaults: speed 1 m/s, +Y direction, LOCAL, all layers, centering/rotation/characters false; strengths 100/50, rotation_step 90°. Options are optional; creation failure returns undefined.
JoltConveyor.destroyJoltConveyor.destroy()Boolean; repeated destruction succeeds. Destroys the conveyor, never its host JoltBody. Further configuration of the destroyed helper fails.
JoltConveyor.get_bodyJoltConveyor.get_body()Stored host or undefined; this method itself does not validate host liveness.
JoltConveyor.get_directionJoltConveyor.get_direction()Copy of normalized {x, y, z} in the chosen LOCAL/WORLD space; undefined on error.
JoltConveyor.get_native_handleJoltConveyor.get_native_handle()Live conveyor handle, otherwise 0. This is not the host body handle.
JoltConveyor.get_speedJoltConveyor.get_speed()Speed in m/s; stored value before set_body. On error returns 0 and records an error.
JoltConveyor.is_validJoltConveyor.is_valid()Boolean for a live native conveyor and host. A pending helper without a host returns false. Losing the host invalidates the conveyor.
JoltConveyor.set_affect_charactersJoltConveyor.set_affect_characters(enabled)Boolean input and result; default false. Transports supported Characters while preserving their input and orientation. The name remains affect_characters; the Explosion rename does not apply here.
JoltConveyor.set_align_rotationJoltConveyor.set_align_rotation(enabled)Alignment: enabled Boolean, step in (0, 360] degrees, finite strength > 0. Defaults false/90/50. Boolean; omitted arguments preserve the current step/strength. Correction torque is scaled by mass.
JoltConveyor.set_bodyJoltConveyor.set_body(body)Live non-sensor Static/Kinematic JoltBody in the same world. Boolean; a failed change preserves the previous conveyor. The host is neither owned nor copied.
JoltConveyor.set_center_objectsJoltConveyor.set_center_objects(enabled)Centering: enabled Boolean, finite strength > 0, defaults false/100. Boolean result; a single-property setter preserves the other value. Strength controls a mass-normalized correction, not one fixed force limit in N for every object.
JoltConveyor.set_center_strengthJoltConveyor.set_center_strength(strength)Centering: enabled Boolean, finite strength > 0, defaults false/100. Boolean result; a single-property setter preserves the other value. Strength controls a mass-normalized correction, not one fixed force limit in N for every object.
JoltConveyor.set_centeringJoltConveyor.set_centering(enabled, strength = center_strength)Centering: enabled Boolean, finite strength > 0, defaults false/100. Boolean result; a single-property setter preserves the other value. Strength controls a mass-normalized correction, not one fixed force limit in N for every object.
JoltConveyor.set_directionJoltConveyor.set_direction(x, y, z)Finite vector with squared length > 1e-12; normalized, length does not affect speed. Default +Y. Boolean; set_space selects the coordinate frame.
JoltConveyor.set_layersJoltConveyor.set_layers(layers = undefined)Transport filter; does not change the collision matrix. undefined = all layers (mask 0); accepts the raycast filter format, resolved mask must be an integer uint32. Boolean; also usable before assigning a host.
JoltConveyor.set_rotation_alignmentJoltConveyor.set_rotation_alignment(enabled, step = rotation_step, strength = rotation_strength)Alignment: enabled Boolean, step in (0, 360] degrees, finite strength > 0. Defaults false/90/50. Boolean; omitted arguments preserve the current step/strength. Correction torque is scaled by mass.
JoltConveyor.set_rotation_stepJoltConveyor.set_rotation_step(step)Alignment: enabled Boolean, step in (0, 360] degrees, finite strength > 0. Defaults false/90/50. Boolean; omitted arguments preserve the current step/strength. Correction torque is scaled by mass.
JoltConveyor.set_rotation_strengthJoltConveyor.set_rotation_strength(strength)Alignment: enabled Boolean, step in (0, 360] degrees, finite strength > 0. Defaults false/90/50. Boolean; omitted arguments preserve the current step/strength. Correction torque is scaled by mass.
JoltConveyor.set_spaceJoltConveyor.set_space(space)Only JOLT_CONVEYOR_LOCAL or JOLT_CONVEYOR_WORLD, default LOCAL. Boolean; local direction rotates with the host.
JoltConveyor.set_speedJoltConveyor.set_speed(speed)Finite speed in m/s; 0 stops, negative reverses direction, default 1. Boolean. Works before and after set_body in the original live world.