Blitz3D+ Command Reference

AnimSeq ( entity )

Parameters

entity - entity handle

Description

Returns the number of the animation sequence an entity is currently playing.

Sequences are numbered from 0, with 0 being the animation that came in with the model and further numbers added by LoadAnimSeq or AddAnimSeq. Reading the current one back lets your state machine avoid restarting a move that is already playing - the usual guard is If AnimSeq(player)<>SEQ_RUN Then Animate player,1,0.5,SEQ_RUN, which stops a run cycle stuttering back to frame 0 every update.

During a crossfade this reports the incoming sequence, the one being blended towards, so the check above still behaves as you would expect.

An entity with no animation returns -1.

See also: Animate, AnimTime, AnimLength, LoadAnimSeq, PlayAnim.

Example

; AnimSeq 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",
; which become sequences 0, 1 and 2
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

; Look up the sequence numbers of the named clips
survey=FindAnimSeq(fox,"Survey")
walk=FindAnimSeq(fox,"Walk")
run=FindAnimSeq(fox,"Run")

; Start the fox looking around
CrossFadeAnim fox,survey,0,1

While Not KeyDown(1)

    ; Switch between the three sequences
    If KeyHit(2) Then CrossFadeAnim fox,survey,10,1
    If KeyHit(3) Then CrossFadeAnim fox,walk,10,1
    If KeyHit(4) Then CrossFadeAnim fox,run,10,1

    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,"1/2/3: play Survey/Walk/Run   Arrows: camera   Esc: exit"
    ; AnimSeq returns the number of the sequence currently playing
    Text 0,20,"AnimSeq(fox) = "+AnimSeq(fox)+"   (Survey="+survey+" Walk="+walk+" Run="+run+")"

    Flip

Wend

End

Index