You want to use this.
when you need to access the script’s properties and methods. For example, on line 3 you’ve added a ‘boxes’ attribute to your script. When you need to access this in the BoxxxManager script’s methods, you would use this.boxes
as you have successfully done on line 7 and 17.
The difference with line 17-19 is that each of the 10 the cloned boxes are not being saved as a property to be accessed later so there is no reason to use this.
. Hypothetically, if you wanted to clone a box and then access it later on in your script, you could do this:
this.clonedBox = this.boxes.clone();
this.clonedBox.enabled = true;
this.clonedBox.setPosition(PosX, PosY, PosZ);
this.entity.addChild(this.clonedBox);
You could then access this.clonedBox
again elsewhere in your script.
** Just be aware the above example code won’t work inside your for loop, it would keep overwriting this.clonedBox every loop.