Playing Animation Group by name?

Lets say I have the list of the available Animation Groups.

How could I choose directly and start the Animation Group that is named “Pistol” ?

Do I have to manually search every time I want to play it via a loop or something going through every element of the animation group array until I find the one that has property name of “Pistol” ?

Currently I “know” by using the debug tools and by console.loging the animation groups that

scene.animationGroups[1].start(false, 2);

plays the desired animation MOST of the time but not ALL the time cause sometimes the animation are ordered differently when I reload the page.

Probably it’s more of JS related question than a BabylonJS one but I’m just wondering if there is a better way than looping through the array and doing on success of finding by name something like :

pistolAnimation = scene.animationGroups[1];
pistolAnimation.start(false, 2);

Well you can call scene.getAnimationGroupByName("Pistol") :slight_smile:

1 Like

I feel like at some point I’m gonna get banned from here for not RTFM.

You are a God.

1 Like