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

script error, anyone help?

Discussion in 'Android' started by dodieboy, Jul 19, 2014.

  1. dodieboy

    dodieboy

    Joined:
    Jul 19, 2014
    Posts:
    3
    i have a error for my random number script
    it show "(9,12): UCE0001: ';' expected. Insert a semicolon at the end."
    but i dont think there is a need to add a semicolon at that place, have i type anything wrong?


    my script
    --------------------------------------------------------------
    import UnityEngine;
    import System.Collections;
    import java.util.Random;

    function Update()
    {
    if(Input.touchCount == 1)
    {
    int q = Random.nextInt(5);
    if(q == 0){i == 1;};
    if(q == 1){i == 2;};
    if(q == 2){i == 3;};
    if(q == 3){i == 4;};
    if(q == 4){i == 5;};
    if(q == 5){i == 6;};
    }
    }
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    1. Select a better topic when you create threads
    2. Use code tags for code snippets
    3. What should if(q == 0){i == 1;}; that do?
     
  3. dodieboy

    dodieboy

    Joined:
    Jul 19, 2014
    Posts:
    3
    if q = 0, said 1 in game (i = text)
     
  4. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    Is this sample code? It looks redundant: q is assigned a value. i is then assigned the value of q + 1.

    Besides that:
    The variable i isn't declared anywhere.
    i is being assigned a value using double equal signs.
    Code (csharp):
    1. int i = 0;
    2. if (q == 0) { i = 1; }
    Though it would be easier just to replace all that with:
    Code (csharp):
    1. int i = q + 1;
     
  5. dodieboy

    dodieboy

    Joined:
    Jul 19, 2014
    Posts:
    3
    o thk, forget to set as variable