Hello everybody
I have a problem and I don’t know how I can fix it (I’m using Javascript).
I want cubes to change color if they are hit with a ball. Each frames the game check if all the cubes are changed color.
var cubo : GameObject[];
var accesi : int; //0 -> spento; 1 -> acceso
accesi = 1;
function Update () {
var i : int;
i = 0;
while(i<cubo.Length()) {
if((cubo*.renderer.material.color == Color.red) && (accesi == 1)) {*
-
accesi = 1;*
-
}*
-
else {*
-
accesi = 0;*
-
}*
-
i += 1;*
- }*
- if (accesi == 0) {*
-
Debug.Log("Tutti spenti");*
- }*
- else if (accesi == 1) {*
-
Debug.Log("Tutti accesi");*
- }*
}
This is the error:
Assets/Script/FineLivello.js(7,22): BCE0077: It is not possible to invoke an expression of type ‘int’.
Here is it what it should do:
There are two variables: cubo which is an array (in English is “cube”) and accesi (in English is “turned on”). For each cube, check if the color is “red” and change “accesi” to 1. If “accesi” is 0 (or the color is not red), do nothing.
When the cicle is ended, check if “accesi” is 0 and show on Debug “Tutti spenti” (= “All turned off”). Else show on Debug “Tutti accessi” (=“All turned on”)
What is the error?
Thanks and sorry for my bad English (I’m Italian) :)