Blitz3D+ Command Reference

ClearAnimRootMotion entity

Parameters

entity - handle of an animated entity

Description

Switches root motion off for an entity and zeroes its reported deltas.

Once cleared, the animation is displayed exactly as authored - including any travel baked into it - and AnimRootMotionX, AnimRootMotionY, AnimRootMotionZ and AnimRootMotionYaw all return 0.

The usual reason to call it is a change of control. A character that walks with root motion but is thrown by an explosion, ragdolled, or handed over to a physics body wants the animation to stop steering it; clearing root motion for the duration is the clean way to do that. It is also worth doing when an entity goes back into a pool, so its next life starts from a known state.

Turning root motion back on later with SetAnimRootMotion starts from a fresh reference pose, so nothing jumps when you do.

See also: SetAnimRootMotion, AnimRootMotionX, AnimRootMotionY, AnimRootMotionYaw.

Example

; ClearAnimRootMotion Example
; ---------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,3,-8
RotateEntity camera,15,0,0

light=CreateLight()
RotateEntity light,45,45,0

ground=CreatePlane()
EntityTexture ground,LoadTexture("media/MossyGround.BMP")

; A courier robot: a named pivot with a cube body
courier=CreatePivot()
NameEntity courier,"CourierRoot"
body=CreateCube(courier)
ScaleEntity body,0.4,0.4,0.6
PositionEntity body,0,0.4,0
EntityColor body,60,220,255

; Author a patrol animation whose keys carry the robot 8 units along X
PositionEntity courier,-4,0,0
SetAnimKey courier,0
PositionEntity courier,4,0,0
SetAnimKey courier,60
patrol=AddAnimSeq(courier,60)
PositionEntity courier,-4,0,0

; Extract root motion without applying it: the movement is stripped from
; the pose, so the robot animates on the spot while deltas are reported
extracting=True
SetAnimRootMotion courier,"CourierRoot",False,False,False

; Play the patrol ping-pong
CrossFadeAnim courier,patrol,0,2

While Not KeyDown(1)

    ; Space toggles extraction. ClearAnimRootMotion switches it off again:
    ; the authored movement returns to the pose (the robot shuttles about)
    ; and the reported deltas drop to zero.
    If KeyHit(57)
        extracting=1-extracting
        If extracting Then SetAnimRootMotion courier,"CourierRoot",False,False,False Else ClearAnimRootMotion courier
    EndIf

    UpdateWorld

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Space: toggle extraction   Arrows: camera   Esc: exit"
    If extracting Then Text 0,20,"Extracting: robot stays put, deltas reported" Else Text 0,20,"ClearAnimRootMotion called: animation moves the robot again"
    Text 0,40,"Root delta X: "+AnimRootMotionX(courier)

    Flip

Wend

End

Index