AnimRootMotionYaw# ( entity )
Parameters
| entity - handle of an animated entity |
Description
|
Returns the root-motion turn the last UpdateWorld produced, in degrees. This is the rotation about the character up axis that the animator baked into the clip - the useful part of a turn-in-place, a combat pivot or a vehicle skid. The value is signed, so it tells you which way the character turned as well as how far, and it is a per-update delta rather than a running angle. Yaw extraction is on by default, so a turn animation gives you numbers as soon as you enable root motion at all. Apply it with TurnEntity player,0,AnimRootMotionYaw(player),0 after each update, or hand it to whatever controls your character heading. With apply True the engine has already turned the entity for you. Pitch and roll are never extracted - they stay on the animated node, which is what keeps a leaning run looking like a leaning run rather than tipping the whole character over. During a crossfade the yaw is blended between the outgoing and incoming clips so the character does not snap round as it changes move. The result is 0 when yaw extraction or root motion is off. See also: SetAnimRootMotion, AnimRootMotionX, AnimRootMotionZ, ClearAnimRootMotion, TurnEntity. |
Example
; AnimRootMotionYaw 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 sentry robot: a named pivot with an arrow-ish body showing its facing sentry=CreatePivot() NameEntity sentry,"SentryRoot" body=CreateCone(8,True,sentry) ScaleEntity body,0.4,0.8,0.4 RotateEntity body,90,0,0 PositionEntity body,0,0.4,0 EntityColor body,190,120,255 ; Author a turning animation: rotation keys that sweep the sentry 120 degrees RotateEntity sentry,0,0,0 SetAnimKey sentry,0 RotateEntity sentry,0,120,0 SetAnimKey sentry,60 sweep=AddAnimSeq(sentry,60) RotateEntity sentry,0,0,0 ; Yaw root motion is only extracted when the yaw flag is True SetAnimRootMotion sentry,"SentryRoot",True,False,True ; Play the sweep ping-pong so the sentry scans left and right CrossFadeAnim sentry,sweep,0,2 While Not KeyDown(1) UpdateWorld ; AnimRootMotionYaw reports the signed turn, in degrees, extracted by ; this UpdateWorld; its sign flips when the ping-pong sweep reverses delta_yaw#=AnimRootMotionYaw(sentry) ; 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,"Arrows: camera Esc: exit" Text 0,20,"AnimRootMotionYaw(sentry) = "+delta_yaw+" degrees this frame" Text 0,40,"EntityYaw: "+EntityYaw(sentry) Flip Wend End
Index