Hi!
Error when cloning an object with a component of sound.
Here is an example:click
Example listener red ball, and all the balls are green have component of sound.
all Positional = true
but it works correctly only in the last clone (large ball is the last clone)
Example code:
pc.script.create('test', function (app) {
var Test = function (entity) {
this.entity = entity;
this.pos = new pc.Vec3();
app.mouse.disableContextMenu();
app.mouse.on(pc.EVENT_MOUSEMOVE, this.onMouseMove, this);
app.mouse.on(pc.EVENT_MOUSEDOWN, this.onMouseDown, this);
};
Test.prototype = {
initialize: function () {
this.enemy = app.root.findByName("sound");
var newenemy=null;
for (i=0;i<5;i++) {
newenemy = this.enemy.clone();
newenemy.setPosition(0,0,0);
newenemy.setEulerAngles(0,pc.math.random(0,360),0);
newenemy.translateLocal(0,0,pc.math.random(-10,10));
newenemy.setName("enemy_instance");
app.root.addChild(newenemy);
if(i===4){
newenemy.setLocalScale(2,2,2);
}
}
},
update: function (dt) {
},
onMouseMove: function (event) {
var cam = app.root.findByName('Camera');
cam.camera.screenToWorld(event.x, event.y, 20, this.pos);
this.pos.y=0;
this.entity.setPosition(this.pos);
}
};
return Test;
});