skip to content

A kinematic character controller standing on a moving lift lags behind it and slides off a rotating platform; how should the controller ride moving platforms?

level: seniorimportance: should knowfreq 42%

answer

  1. nothing carries a kinematic character
  2. remember what you stand on
  3. the platform's motion at the foot point
  4. inherit velocity on take-off

basics

~20 s

Track the platform under the character; each step, after the platform moves, carry the character by the platform's displacement at its foot point, rotation included, then apply its own movement. On leaving, inherit the platform's velocity at that point.

solid answer

~50 s

A kinematic controller is not dragged along by solver friction, so unless the code carries it, a moving platform simply moves out from under it or pushes into it. If the character also updates before the platform in a step, it reads last step's pose and lags. The fix: remember the ground collider from the ground check, update platforms first, then compute the platform's displacement at the character's foot point, `delta = M_now * inverse(M_prev) * p - p`, which includes rotation; move the character by `delta` (through collision so walls still block), turn its facing by the platform's yaw change, and only then run its own collide-and-slide. When it jumps or walks off, add the platform's point velocity `v + cross(w, p - c)` to its air velocity, so leaving a moving lift or train does not snap it backward.

code

pseudocode · 14 lines
pseudocode
function carryByPlatform(character):
    platform = character.groundCollider
    if platform is none or not platform.isMoving:
        return
    foot = character.footPosition
    movedFoot = platform.worldNow * inverse(platform.worldPrev) * foot
    carry = movedFoot - foot
    character.position = moveAndSlide(character.position, carry)   // sweep ignores this platform
    character.yaw = character.yaw + platform.yawNow - platform.yawPrev

function onLeaveGround(character, platform):
    r = character.footPosition - platform.centerOfMass
    character.velocity = character.velocity + platform.linearVelocity
                         + cross(platform.angularVelocity, r)

go deeper

for a junior

Recall that a kinematic character is not dragged by a moving platform, so code must carry it and give it the platform's speed when it jumps off.

for a middle

Explain how the platform's displacement at the foot point is computed from transforms, why platforms update first, and how point velocity is inherited.

for a senior

Diagnose lag, descending-lift flicker, orbiting without turning and snap-back jumps, and handle crushing, nested platforms and mismatched visual interpolation.

for a principal

Decide one platform-riding contract for the whole game: which objects count as platforms, update order, crush rules and inheritance, so features do not each invent their own.

## Why the character falls behind A dynamic rigid body standing on a moving platform is carried by **friction**: the solver's contact constraints drag it along. A **kinematic character controller** gets none of that, because it moves only by its own shape casts. So a platform moving under a kinematic character does one of three things: - a platform moving **sideways** slides out from under it; - a platform moving **up** pushes into the capsule, and the character is shoved or ends up overlapping it; - a platform moving **down** drops away, the ground check misses, and the character falls a little every step, flickering between grounded and airborne. **Update order** makes it worse. If characters run their movement before platforms move in the same step, every character works against last step's platform pose and is always one step behind it, which reads as lag at speed and as jitter when the step length varies. ## Carrying the character with the platform The robust method is to make the character move with the platform explicitly: 1. **Remember the ground.** The ground check already returns the collider under the character; store which platform it is. 2. **Move platforms first.** Platforms are kinematic bodies driven by animation or scripts; update them before characters, and move them by setting target poses so the physics system knows their velocity, rather than teleporting them. 3. **Compute the platform's displacement at the foot point.** With the platform's world transform last step `M_prev` and now `M_now`, the foot point `p` moves to `M_now * inverse(M_prev) * p`. The displacement is that minus `p`. Because it uses whole transforms, it includes rotation: a character standing off-centre on a turntable is carried around the circle, not just shifted. 4. **Turn the character.** Add the platform's change in yaw to the character's facing, so it rotates with a turntable instead of staring at a fixed direction while orbiting. 5. **Apply the carry, then the character's own move.** Run the carry displacement through the same collide-and-slide sweep, ignoring the platform itself (it has already moved and may now touch the capsule), so a wall on the platform or the lift shaft still blocks it; then run the character's input and gravity as usual. Many games instead **parent** the character to the platform's transform while grounded on it. That works when the platform hierarchy is simple, but it inherits scale and nested transforms, and it has to be undone carefully on leaving. ## Leaving the platform When the character jumps or walks off, the carry stops. If nothing else changes, the character keeps only its own velocity, so jumping from the back of a moving train makes it stop dead in the air relative to the world and snap backward relative to the train. The fix is to **inherit the platform's velocity at the take-off point**: - `v_point = v + cross(w, p - c)`, where `v` is the platform's linear velocity, `w` its angular velocity and `c` the point `v` is measured at (usually its centre of mass); - add `v_point` to the character's air velocity, so a rising lift adds to the jump and a train's speed carries the character forward; - optionally fade it out over time if the design wants air control to dominate. ## Edge cases to plan for - **Crushing.** A lift rising into a low ceiling, or a platform pushing the character into a wall, leaves no position where the capsule fits. Decide the rule (kill, push sideways, stop the platform) instead of letting the controller end inside geometry. - **Platforms on platforms.** A boat on a moving river barge needs the carry applied from the outermost platform inwards, or the character's own platform transform already includes its parent's motion. - **Visual jitter.** If platforms are drawn with interpolation between physics steps and the character is not, or the reverse, the two drift by part of a step on screen even when the simulation is exact; both must use the same presentation rule. - **Dynamic platforms.** A crate pushed by physics can serve as a platform the same way, using its transforms before and after the step, but it may also respond to the character's weight, which the kinematic controller must push back on deliberately.

  • Why is adding only the platform's linear velocity not enough?
    On a platform that rotates, points away from the pivot move along circles, and the platform's linear velocity describes only the pivot. A turntable spinning in place has zero linear velocity, so a character carried that way would not move at all. Using the full transform change, or `v + cross(w, r)`, captures the rotation.
  • Why move platforms by target pose instead of setting their position directly?
    Setting a kinematic body's target lets the physics system derive its velocity for the step, so dynamic objects resting on it are carried by contact and the controller can read a velocity to inherit. Teleporting gives the platform no velocity: objects on it stay behind, and contacts are resolved as sudden overlaps.

  • Friction will carry a kinematic character on a platform
  • Adding the platform's linear velocity handles rotating platforms
  • Update order between platforms and characters does not matter
  • Keep carrying the character by the platform while it is airborne
  • Parenting to the platform has no downsides