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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Help with a script.

Discussion in 'Scripting' started by owa666, Aug 10, 2015.

  1. owa666

    owa666

    Joined:
    Aug 10, 2015
    Posts:
    2
    Hi everyone, first off, I'd like to say sorry if this is in the wrong spot, but here it goes.

    I'm having trouble with this script



    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var rotationSpeed = 100;
    4. var jumpHeight = 8;
    5.  
    6. private var isFalling = false;
    7.  
    8. function Update () {
    9.     //Moves left/right on x axis
    10.     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    11.     rotation *= Time.deltaTime;
    12.     rigidbody.AddRelativeTorque (Vector3.back * rotation);
    13.    
    14.     //Makes the ball jump on the Y axis with W.
    15.     if (Input.GetKeyDown (KeyCode.W) && isFalling == false)
    16.    
    17.     (rigidbody.velocity.y) = jumpHeight;
    18.     isFalling = true;
    19.  
    20. }
    21.  
    22. function OnCollisionStay
    23. (
    24.     isFalling = false
    25. )
    I'm getting the errors

    Assets/Movement.js(24,19): BCE0043: Unexpected token: =.
    and
    Assets/Movement.js(26,1): BCE0043: Unexpected token: .

    Which I don't understand-I don't have anything on line 26??

    The script is for movemen and a simple jump.

    I'm using Unity 4
     
  2. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    968
    You've should have parentheses after function OnCollisionStay, and a semicolon after isFalling = false, and you should have curly braces around your function, not parentheses. Look at the Update function, it's correct there.

    Syntax errors like these will often propagate beyond where the actual error is.
     
  3. owa666

    owa666

    Joined:
    Aug 10, 2015
    Posts:
    2
    Thank you very much. I knew i was most likely an easy fix :)