Skip to content

engine: physics steps before motion in each fixed step, so every followed body chases last step's rig #845

Open

Description

@nicolas-maman

The latency. Behaviours run their fixed_update in the order they were added (engine.run_fixed_updates), and physics.attach adds the physics behaviour before motion.on_figure adds motion's. So within each fixed step:

  1. the bodies are stepped toward the anchors' targets, which are the rig as motion drew it in the previous step;
  2. only then does motion work out this step's pose and draw the rig.

Every followed body (ACTING, ANIMATED) therefore chases a target one step stale. Unity, and PuppetMaster on it, run the scripts' FixedUpdate, with the animation read there, before the physics step for this reason. Unreal's physical animation sets its targets before the physics tick.

Measured (the #843 probe). The box man sat on a 0.38 m log raises a bowl to its mouth, the hand moving at up to 0.94 m/s, with its arms' anchors pinned at 30 Hz. The forearm bodies end up 4.9 cm behind the grips the drawn hands are on. A critically damped 30 Hz anchor should trail a 0.94 m/s target by about 1.0 cm. Stiffening the pin shows the floor:

pin worst lag mid-bite
30 Hz 4.9 cm
60 Hz 3.7 cm
120 Hz 2.7 cm

The lag tends toward a floor of a step or more of motion (1.6 cm a step at that speed) rather than toward the spring's own lag.

Wanted. The physics behaviour steps after every other behaviour's fixed_update in the same fixed step, so the bodies chase this step's targets. This shifts every motion test's timing by a step, so it needs the full motion gate, the plaza and the showcase against main, and a pass over the gains tuned with the lag in place.

Activity

  1. nicolas-maman commented on Oct 21, 2026

    @nicolas-maman
    CollaboratorAuthor

    Measured with a knob that runs the physics behaviour's fixed_update after every other behaviour's, in the same fixed step. The patch is build/scratch/physics_last_knob.patch: X_PHYSICS_LAST=1, matched on the behaviour named "physics".

    The hold probe (#843's case, with #846's arm pins):

    physics first (now) physics last
    mid-bite lag of the forearm bodies 4.9 cm 3.5 cm
    average 1.09 cm 0.88 cm

    The 1.4 cm gained is about one step of the hand's motion, as expected.

    The motion gate: 41 of 42 suites pass unchanged. The one that moves is test_falls, "forwards: the knees are down first, then the hands, in at least 29". It goes to 28 of 30: two protected forward falls land a hand first. The protective fall's arms take hold a step sooner, which may be the arms being quicker rather than a defect.

    For the PR:

    • Sweep that count on main against the branch over more pairs and seeds before judging it.
    • Check the plaza scorecard and the showcase against main.
    • Think through what the order means for gameplay scripts. With physics stepping last, a script's fixed_update sees the previous step's physics, as Unity's FixedUpdate does.
  2. nicolas-maman commented on Oct 22, 2026

    @nicolas-maman
    CollaboratorAuthor

    Moved under the animation epic #853, milestone #858 (the physics asset and physical animation layer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions