Execute code action

Hi everyone! I am looking to do some optimizations and ran into a problem with executing actions on a skinned mesh. Distilling the problem down, I managed to repro here: https://playground.babylonjs.com/#YG34ZR#1

In the commented parts, my own source uses scene.beginAnimation which is a really dirt simple single bone translation to move green/blue boxes up/down. How can I modify my actions to do the same w/o using beginAnimation? Ideally, I would like to run InterpolateValueAction on position.y of the boxes while keeping currStage, as it can change at runtime. Is this still possible ?

I am not sure to understand the difference as interpolateValueAction would still internally create and start an animation ?

maybe you could use PlayAnimationAction ?

oh, that’s because I want to reduce unnecessary keyframed animations in my .babylon file to reduce filesize. I reckon that interpolateValueAction would allow me to translate a bone target which is identical to what the keyframed anim is doing. And I can move my anims into code. But as far as the doc goes, it seems like (interpolateValueAction / PlayAnimationAction ) actions cannot be manually triggered in the conditional flow of executeCodeAction?

As in, ideally it should be

if (condition A){
    execute interpolateValueAction #1
} else (condition B) {
    execute interpolateValueAction #2
} etc...

In the PG, there are only 2 boxes reactions but in reality, its more of having n sphere colliders with m conditions hence the currStage param to control visual result. I guess the question is whether its possible to manually execute an action that has no trigger ?

I had the fancy idea of trying out IVAs with combineAction and found that it does not respect individual action conditions ? Repro: https://playground.babylonjs.com/#YG34ZR#2

wai ?

The condition is currently only checked on the main combine action and all children will execute independently of their own conditions. Let me check how best we could sort it.

This should do Allow combineAction child condition check by sebavan · Pull Request #11045 · BabylonJS/Babylon.js · GitHub :slight_smile: it will allow you to check children animations conditions in combineAction

1 Like

Yay, it works. Thanks, marking as solved! :slight_smile:

1 Like