[SOLVED] Get name of animation asset

I am working in the editor and have an animated model. Means it has the animation component and 2 assigned animation clips (new glb system).

in code I want to switch some animations, but not by name. In this case I would prefer to play animations by array ID, where the array consists of the assigned anims in the editor.

However …animation.play(“wantsToHaveAnAnimationclipName”)

I read some forum topics but nothing works. I get asset ids but no names:

        var idleAnim = this.characterAnimEntity.animation.assets[1];
        console.log(idleAnim); // returns asset id
        console.log(idleAnim.name); // returns undefined
        //this.characterAnimEntity.animation.play(idleAnim, 1 ); // error

how do I get the name?

Hi @Marjan,

If you have the asset id, you can easily get the name by getting first a reference to the pc.Asset:

// get asset from asset registry using ID
var asset = this.app.assets.get(assetId);
var name = asset.name;
1 Like

WOW, you guys are so cool! Works!

1 Like