AnimRootMotionY# ( entity )
Parameters
| entity - handle of an animated entity |
Description
|
Returns the vertical root-motion distance the last UpdateWorld produced. Vertical motion is not extracted by default, so this returns 0 unless you passed vertical as True to SetAnimRootMotion. That default is deliberate: most walk and run cycles bob up and down a little, and you rarely want that bob turned into real movement that fights your gravity code. Where it earns its keep is authored jumps, vaults, climbs and mantles - moves where the artist decided exactly how high the character goes, and the game should honour that instead of guessing. Switch vertical extraction on for the duration of the move, add the value to your own vertical movement, and switch it off again afterwards. As with the other root-motion queries the value is a per-update delta in the entity local model space, not a running total, and it is 0 when root motion is off. See also: SetAnimRootMotion, AnimRootMotionX, AnimRootMotionZ, ClearAnimRootMotion. |
Example
; AnimRootMotionY Example ; ----------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-8 RotateEntity camera,8,0,0 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") ; A spring-loaded robot: a named pivot with a cube body hopper=CreatePivot() NameEntity hopper,"HopperRoot" body=CreateCube(hopper) ScaleEntity body,0.4,0.4,0.4 PositionEntity body,0,0.4,0 EntityColor body,255,180,60 ; Author a hop: keys that lift the robot 2 units up and drop it back PositionEntity hopper,0,0,0 SetAnimKey hopper,0 PositionEntity hopper,0,2,0 SetAnimKey hopper,15 PositionEntity hopper,0,0,0 SetAnimKey hopper,30 hop=AddAnimSeq(hopper,30) PositionEntity hopper,0,0,0 ; Vertical root motion is only extracted when the vertical flag is True SetAnimRootMotion hopper,"HopperRoot",True,True,False ; Loop the hop forever CrossFadeAnim hopper,hop,0,1 While Not KeyDown(1) UpdateWorld ; AnimRootMotionY reports the vertical movement extracted by this ; UpdateWorld: positive going up, negative coming down delta_y#=AnimRootMotionY(hopper) ; 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,"AnimRootMotionY(hopper) = "+delta_y+" this frame" Text 0,40,"EntityY: "+EntityY(hopper) Flip Wend End
Index