Search Unity

Superbly Simple Question (to do with JavaScript)!

Discussion in 'Scripting' started by playbass06, Mar 6, 2010.

  1. playbass06

    playbass06

    Joined:
    Feb 17, 2010
    Posts:
    5
    I am entirely new to scripting, to say the least, but I've been spoiled on Blender's logic bricks, so I decided it was time to learn and move on to better game engines.
    Now I have no clue what I'm doing, but I did find some tutorials. As far as I can tell, the following script seems fine, but I get an error telling me:
    Assets/NewBehaviourScript.js(3,40): BCE0044: expecting :, found ';'.

    Code (csharp):
    1. function Update () {
    2. if (Input.GetButton("Jump"));{
    3.     OpenScene("Assets/scene.unity");
    4.     }
    5. }
    (simply saying if the spacebar(Jump) is pressed, open scene.unity)
    I know I'm making some simple easily overlooked mistake, but I don't exactly know what I'm looking for anyway...

    Thanks,
    playbass06
     
  2. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Code (csharp):
    1. function Update () {
    2. if (Input.GetButton("Jump")){
    3.    OpenScene("Assets/scene.unity");
    4.    }
    5. }
     
  3. Ramen Sama

    Ramen Sama

    Joined:
    Mar 28, 2009
    Posts:
    561
    Ah, beat me to it. you have a semi where your shouldn't. The editor detects the error on the next line which might be why you didn't see it!
     
  4. playbass06

    playbass06

    Joined:
    Feb 17, 2010
    Posts:
    5
    I would think that would solve it, also, but I did try that.
    Unity gives me the error:
    BCE0005: Unknown identifier: 'OpenScene'.

    (10 minutes later...)
    I fixed it by replacing OpenScene with Application.LoadLevel, and it now works just fine!
    Thanks for your patience.