Conditional Imported Mesh Animations

Hello everyone,

I’ve been able to successfully get imported mesh animations to change with events such as a button press. For instance, button press = beginAnimation or stopAnimation.

However, I cannot get the same result based on a conditional. In the PG below, the goal is for animation 1 to play if var go = true, and animation 2 to play if var go = false. I added buttons to switch between true and false.

If you use the buttons to start each animation directly, it works.

Any help or advice would be greatly appreciated! :smiley: :+1:

https://playground.babylonjs.com/#QY1WYT#246

If you set the variable before the load ends like here https://playground.babylonjs.com/#QY1WYT#247

it plays the correct animation.

replacing the var value to true instead works as well.

I am not sure what exact issue you are facing ?

Hello @sebavan,

The mesh has multiple animations separated by frames.

Frames 0 to 72 = Jump
Frames 73 to 100 = Fall

If the variable is set to true, the fall animation should start and loop.
If the variable is set to false, the jump animation should start and loop.

Thanks for helping with this!

This is exactly what I am seeing, is it not the case for you ?

I see the jump animation, but the “go = true” button has no effect :thinking: Am I missing something?

oh so for the button to work as well they need to not override to go with the var keywords:

https://playground.babylonjs.com/#QY1WYT#251

1 Like

Excellent, thanks again for the help! :smiley: :+1: