okay I have followed parts of this [SOLVED] Spawn entity at certain time
but something is working yet something is not, I have a coin that is place in a specific place in 3D space, I created an empty entity and assigned this code:
var Spawner = pc.createScript('spawner');
Spawner.attributes.add('objectToSpawn', {
type: 'entity'
});
// initialize code called once per entity
Spawner.prototype.initialize = function() {
setInterval(()=>{
console.log('called');
let clonedObj = this.objectToSpawn.clone();
console.log(clonedObj);
let root = this.app.root;
root.addChild(clonedObj);
clonedObj.setLocalPosition(this.entity.getLocalPosition().x, this.entity.getLocalPosition.y, this.entity.getLocalPosition.z);
}, 2000);
};
Spawner.prototype.update = function(dt) {
};
what I am trying to do is, add that entity that I want to clone as an attribute and then on interval I want to clone that thing and then add it to the root and then change its position, something isn’t working and I don’t know what is it