Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unexprcted Token Error.

Discussion in 'Scripting' started by DavidJess, Dec 15, 2014.

  1. DavidJess

    DavidJess

    Joined:
    Dec 12, 2014
    Posts:
    6
    This is the code below the error is:

    Assets/placePickups.js(8,18): BCE0043: Unexpected token: 2.


    Code (JavaScript):
    1. #pragma strict
    2. var objectToCreate : Transform;
    3. var radius : int;
    4.  
    5.  
    6. function Start () {
    7.  
    8.     for (var 1 : int = 0;1 < 5; 1++)
    9.     {
    10.         var randWithinCircle = Random.insideUnitSphere * radius;
    11.         var pickUp = Instantiate (objectToCreate, Vector3(936 + randWithingCircle.x, 8, 1080 + radWithinCircle.z), Quaternion.identity) as GameObject;
    12.     }
    13. }
     
  2. Kirk Clawson

    Kirk Clawson

    Joined:
    Nov 4, 2014
    Posts:
    65
    That looks suspiciously like a number 1 after the var keyword. You can't use numbers as variable names. Use a letter instead (most people choose i), I'll use the letter x, just so it's easy to differentiate on the web page:

    Code (JavaScript):
    1. for (var x : int = 0;x < 5; x++)
     
    DavidJess likes this.