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;
    
          }
    

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
 }

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 :slight_smile: