Hi everyone,
I am having a problem when referring to an array of entities as it catalogues it as “undefined”, despite it is returning me its length so it exists:
var GetColorPanel = pc.createScript('getColorPanel');
GetColorPanel.attributes.add('palanca', {type: 'entity' });
GetColorPanel.attributes.add('doorA', {type: 'entity', array: true, default: [""], title: "Example Entity Array"});//entity a la que queremos cambiar la textura
//ExampleScript.attributes.add("entities", {type: "entity", array: true, default: [""], title: "Example Entity Array"});
var angle = 0;
var percentageIntensity;
var initialIntensity;
// initialize code called once per entity
GetColorPanel.prototype.initialize = function() {
angle = this.palanca.getRotation().y;
};
// update code called every frame
GetColorPanel.prototype.update = function(dt) {
var self = this;
angle = this.entity.getEulerAngles().y;
percentageIntensity = (angle + 90) / 180;
console.log('len: ' + this.doorA.length);
var i;
for(i=0;i<=this.doorA.length;i++)
{
self.doorA[i].entity.script.receiveChangeOrder.open(percentageIntensity);
}
I tried also in other script:
var i;
for(i=0;i<=this.doorA.length;i++)
{
console.log("var " + i);
this.doorA[i].model.meshInstances[0].material.diffuse.set(tramoRed, tramoGreen, tramoBlue);
this.doorA[i].model.meshInstances[0].material.update();
console.log("this is " + tramoRed + "this is " + tramoGreen + "this is " + tramoBlue);
}
i found in the forum very similar topics but none of them have been of help in my case.
No mater what i change the error is always the same: “(X).doorA[i].(X) is undefined”
Thanks a lot for your help