AnimationSetError$ ( )

Parameters

None.

Description

Returns why the last CreateAnimationSet, ApplyAnimationSet or PlayAnimationSet failed.

Each of those commands clears it before it starts, so read it straight after a failure:

robot=CreateAnimationSet(asset)
If robot=0 Then RuntimeError AnimationSetError()

Returns "" after a success.

For the full story - clip modes, speeds, events and root motion - see the Animation sets guide and its complete AnimationSets.bb sample.


See also: CreateAnimationSet, ApplyAnimationSet, PlayAnimationSet.

Example

; CreateAnimationSet Example
; --------------------------

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

camera=CreateCamera()
PositionEntity camera,0,2,-7

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

; The robot's animation set: clip names, speeds, blends and step events
document=LoadResourceDocument("../../../samples/animation-sets/robot.animset")
If document=0 Then RuntimeError ResourceDocumentError()
library=LoadResourceDocumentAsync(document)
FreeResourceDocument document
While Not WorldReady(library)
    If WorldLoadState(library)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(library)
    UpdateAsyncLoads 2
Wend
asset=FindWorldAsset(library,"resource")

; A robot made from the set, ready to play its clips by name
robot=CreateAnimationSet(asset)
If robot=0 Then RuntimeError AnimationSetError()
PositionEntity robot,-1.5,0,0

; An ordinary animated model, given the same settings
twin=LoadAnimMesh("../../../samples/animation-sets/robot.gltf")
If Not ApplyAnimationSet(twin,asset) Then RuntimeError AnimationSetError()
PositionEntity twin,1.5,0,0

; Both robots keep their settings when the loader world goes
FreeWorld library

PlayAnimationSet robot,"walk"
PlayAnimationSet twin,"walk"
report$="PlayAnimationSet robot,"+Chr(34)+"walk"+Chr(34)+" returned True"
problem$=""
step_event$=""

While Not KeyDown(1)

    ; 1 / 2 cross-fade both robots, 3 asks for a clip the set lacks
    clip$=""
    If KeyHit(2) Then clip="walk"
    If KeyHit(3) Then clip="run"
    If KeyHit(4) Then clip="fly"
    If clip<>"" Then
        If PlayAnimationSet(robot,clip) Then
            PlayAnimationSet twin,clip
            report="PlayAnimationSet robot,"+Chr(34)+clip+Chr(34)+" returned True"
            problem=""
        Else
            report="PlayAnimationSet robot,"+Chr(34)+clip+Chr(34)+" returned False"
            problem=AnimationSetError()
        EndIf
    EndIf

    ; The set's step events arrive like any animation event
    While PendingAnimEvents(robot)>0
        step_event=PollAnimEvent(robot)
    Wend

    ; 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

    UpdateWorld
    RenderWorld

    Text 0,0,"Arrow keys: move camera   1 / 2: walk / run   3: unknown clip   Esc: exit"
    Text 0,20,"Left: CreateAnimationSet   Right: LoadAnimMesh + ApplyAnimationSet"
    Text 0,40,report
    Text 0,60,problem
    Text 0,80,"Latest step event: "+step_event

    Flip

Wend

End

Index