The activate property is only used when the component is added to the entity: https://developer.playcanvas.com/en/api/pc.AnimationComponent.html#activate
After it’s been added, it has no effect.
Use play() to play the animation if you want the animation to play later. https://developer.playcanvas.com/en/api/pc.AnimationComponent.html#play
Example with timeout:
// initialize code called once per entity
App.prototype.initialize = function() {
var app = this.app;
var url = "https://raw.githubusercontent.com/yaustar/yaustar.github.io/master/test-anim-glbs/male.glb";
var aniUrl = "https://raw.githubusercontent.com/yaustar/yaustar.github.io/master/test-anim-glbs/Idle%20(3).glb";
var entity;
app.assets.loadFromUrl(url, "container", function (err, asset) {
entity = new pc.Entity();
entity.addComponent("model", {
type: "asset",
asset: asset.resource.model,
castShadows: true
});
app.assets.loadFromUrlAndFilename(aniUrl, "idle.glb", "animation", function (err, animAsset) {
entity.addComponent("animation", {
activate: false,
assets: [animAsset],
});
app.root.addChild(entity);
});
});
setTimeout(function() {
entity.animation.play('idle.glb', 0);
}, 3000);
};