- Home /
The question is answered, right answer was accepted
unexpected token :var ?
Hello, first time i try to use i incremantation. But something is wrong but why ?
on line (var i=0;i<(x*y);i++) error.
for (var x=0;x<PieceLongueurTaille;x++) { var pos = Vector3 (x, 0, y) * spacing; var mapiece = Instantiate(block, pos, Quaternion.identity) as GameObject; mapiece.transform.SetParent(transform, false); (var i=0;i<(x*y);i++) mapiece.name = "block"+i; }
Answer by Reynarz · Jul 18, 2017 at 02:11 PM
Use the type "int" directly, "var" is meaning of "i will figure out what value type is in the right hand".
But... you forget the "for" keyword.
for (var i= 0; i < (x * y); i++)
{
//Do something
}
But i use var i just after ? I have try (int i=0;i<(x*y);i++) but that not what you suppose, but i dont know how to do with your int.
Answer by agencebrunel · Jul 18, 2017 at 02:22 PM
Thanks, i have make at top a declaration : var i : int = 0;
Then inside start : i++; mapiece.name = "block"+i;
Thanks you i learn with your help :)
Follow this Question
Related Questions
with var and without var creates different effects 1 Answer
Can't get var from other script. 1 Answer
How can i link a var to a gui? 2 Answers
if (var == true) do something... not being detected 2 Answers
Animation variables in javascript 0 Answers