Trouble getting animation script to work properly


Hello, I’ve run into a trouble, when trying to play every animation attached to an entity:

Here’s what I’m trying to do:

I have a set of entities with animations attached to them and on a certain event, I want to play all of them, regardless of the names and things like that. Judging from this link: the code should look somewhat like this:

for (var animIndex = 0; animIndex < this.animations.length; animIndex++) {
    var animComponent = this.animations[animIndex].animation;
    for (var assetIndex = 0; assetIndex < animComponent.assets.length; assetIndex++) {
        var animAsset = animComponent.assets[assetIndex];
        //console.log("Asset: " + animAsset.toString() + "; name: " +;;

the problem is, that the is undefined and when I try to print animAsset, it prints only the id (which is correct, by the way) and the expected fields it should have are missing.

I made an assumption, that the documentation might be incorrect and there are only ids and nothing else in animComponent.assets and when trying to get Asset from id using the things from this link: nothing worked, because ‘app’ is no more a thing in playcanvas.

Can anyone provide some help?


Well… As it turns out, app is now and the animComponent.assets thing is a list of asset ids. Would anyone bother with updating the documentation?


It’s a little difficult because it depends on what context the code is being ran in. The sample code was meant to show that you should be using an instance of the app (which could be made more clear I guess?). In some cases where you are using the engine without the editor, you may also have a reference to the app somewhere already. (You can see an example here:

If you are in a pc.script, it would be There is a ‘global’ instance of at but that is only assigned on the first tick (I can’t quite remember) of the engine running. really shouldn’t be used as there may be more than one app running on the page (rare but possible).


Thanks for the information


And how is the solution for this issue? I run into the same right now.


What’s the problem you are running into?


I want to play the first animation (or the second) of an entity. I tried this:[0],1);

But myEntity.animation.assets[0] does return the id and play can’t work with it. So how do I get the name out of this?


Turns out there are properties that you could use instead (not public, but far easier to use):

Not tested, but I imagine it be something like this:[0]),1);


Thank you very much!
One small correction cause animationsIndex is an array:[(myEntity.animation.assets[0]],1);