Contents

AnimationEvents.RootMotionDidUpdate

The event raised each frame when a new root motion delta is produced for an entity.

Declaration

struct RootMotionDidUpdate

Overview

Root motion is locomotion that’s authored into an animation itself — for example, a run cycle whose root joint advances forward — rather than driven by code. Each frame’s contribution is reported as a rootMotionTransform delta, which the system applies to the entity’s transform automatically. The event fires after animation evaluation but before the resulting skeletal pose is applied to the mesh.

Subscribe to this event when you need to take over root motion application — for example, to project the delta onto a navigation surface or to reject motion on collision. By default, subscribing through scene.subscribe(to:on:) suppresses the automatic application; the subscriber is then fully responsible for applying or discarding the delta.

Take over root motion application

scene.subscribe(to: AnimationEvents.RootMotionDidUpdate.self, on: entity) { event in
    entity.transform = event.rootMotionTransform * entity.transform
}

Observe root motion without taking over

To observe the delta while leaving automatic application in place, set suppressesAutomaticApplication to false inside the handler:

scene.subscribe(to: AnimationEvents.RootMotionDidUpdate.self, on: entity) { event in
    event.suppressesAutomaticApplication = false
    print("Delta: \(event.rootMotionTransform)")
}

Topics

Accessing root motion

Instance Properties