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: https://developer.playcanvas.com/en/api/pc.AnimationComponent.html#assets the code should look somewhat like this:
the problem is, that the animAsset.name 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: https://developer.playcanvas.com/en/api/pc.AssetRegistry.html#get nothing worked, because ‘app’ is no more a thing in playcanvas.
Well… As it turns out, app is now pc.app 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: https://github.com/playcanvas/engine/blob/master/examples/load_model/index.html)
If you are in a pc.script, it would be this.app. There is a ‘global’ instance of at pc.app but that is only assigned on the first tick (I can’t quite remember) of the engine running. pc.app really shouldn’t be used as there may be more than one app running on the page (rare but possible).
Yeah, but all animation clips in the Animation Blending tutorial are set in the Editor manually.
I want to attach all animations in my script and play them. Because, you know, it is not very convenient to attach animation clips manually if I have 100+ of them.
I have no problems loading animation assets (console.log(this.entity.animation.assets[0].name) is working), but I can’t play this animation clip.