I changed the material of a template at runtime, but when I try to get the new color, it is returning me as if I had not changed it.
Action.prototype.createBalls = function() {
clampBall = pc.app.assets.get("44923196");
balls = pc.app.root.findByName("balls");
var x = this.columnsIni;
var y = this.rowIni;
for(var i =0; i<this.rows; i++){
for(var a=0; a<this.columns; a++){
//Initial position
if(a===0){
if(i % 2===0){
x = this.columnsIni;
}else{
x = this.columnsIni + this.ballEspaceAjust;
}
}
//new instance
if((i % 2===0) || ( a <(this.columns-1))){
instance = clampBall.resource.instantiate();
balls.addChild(instance);
instance.setPosition(x,y,0);
//instance.name = instance.name + '_' + i + '_' + a;
color = Math.floor(Math.random() * this.colors.length);
instance.model.meshInstances[0].material = this.colors[color].resource;
}
x = x + this.ballEspace;
}
y = y - (this.ballEspace-0.06);
}
//position of game
var xGameTotal = (this.ballEspace * this.columns)-this.ballEspace;
var gamePosition = (xGameTotal/2);
balls.setPosition(-gamePosition,0,0);
};
helllpp me