Animating ( entity )
Parameters
| entity - entity handle |
Description
|
Returns True while an entity is animating, False when it is not. The natural use is waiting for a one-shot move to finish: play an attack or a death with mode 3, then each frame check If Not Animating(entity) and move the character on to its next state. It also stays True during a crossfade, so a blend counts as animating. A looping or ping-pong animation never stops on its own, so Animating stays True until you call Animate with mode 0. An entity with no animation at all returns False rather than raising an error, which makes it safe to call on a mixed bag of entities. See also: Animate, AnimTime, AnimSeq, AnimLength, PlayAnim. |
Example
; Animating Example ; ----------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 RotateEntity camera,12,0,0 light=CreateLight() RotateEntity light,45,45,0 ; A grassy paddock for the fox to roam ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") ; Load the rigged fox; it has the named clips "Survey", "Walk" and "Run" fox=LoadAnimMesh("../../../samples/glTF/assets/Fox/Fox.glb") If fox=0 Then RuntimeError "Could not load Fox.glb: "+ModelLoadError() ; Shrink the fox to game scale (the file is modelled about 100 units tall) FitMesh fox,-0.8,0,-0.8,1.6,1.6,1.6,True run=FindAnimSeq(fox,"Run") While Not KeyDown(1) ; Space plays the run clip once; when the one-shot finishes, ; Animating drops back to 0 If KeyHit(57) Then Animate fox,3,1,run,10 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: play one-shot Run Arrows: camera Esc: exit" ; Animating returns True while a sequence is still playing Text 0,20,"Animating(fox) = "+Animating(fox) Flip Wend End
Index