Hi,
I did the following to create an animation component and then play it programatically. But it’s not playing and also there is no errors in DevTools. What am I doing wrong?
MyScript.prototype.initialize = function () {
var self = this;
this.app.assets.loadFromUrl(’/testAnim.json’, ‘animation’, function (err, asset) {
self.entity.addComponent(‘animation’, {
assets: [asset],
speed: 1
});
console.log(self.entity.animation);
self.entity.animation.play(asset.name);
});
};
I got console.log(self.entity.animation) - ‘model’ and ‘skeleton’ properties are all ‘null’ but I see that ‘assets’ is an array of the correct asset which is ‘testAnim.json’, which I am assuming the animation json is loaded but something wrong either the json file or somewhere. Is this the right way to load an external animation?
** forgot to mention that I used Playcanvas editor to import the FBX w/ animation embedded and downloaded the model json and also animation json manually to use in my code.
Thank you,