Search Unity

help me out!

Discussion in 'Scripting' started by Muzzammil, Oct 24, 2014.

  1. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
    hey guys why does this code not work to my game? please write down the fail to me ;)
    #pragma strict


    var rotationSpeed = 100;

    function Update
    var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    Rigidbody.AddRelativeTorque (Vector3.back * rotation);
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use verbose topic titles.
     
    StarManta likes this.
  4. Shukerullah

    Shukerullah

    Joined:
    Mar 15, 2013
    Posts:
    97
    put 100 instead of rotationSpeed
    var rotation : float = Input.GetAxis ("Horizontal") * 100;

    rotationSpeed is public variable, i think you might have put 0 value in inspector.
     
  5. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
  6. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
    sukerullah it still the same i have changed it
     
  7. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
    ???? !


    #pragma strict


    var rotationSpeed = 100;

    function Update
    var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    Rigidbody.AddRelativeTorque (Vector3.back * rotation); this is my code but it stil says Assets/ballcontrol.js(7,4): BCE0044: expecting (, found 'var'. and Assets/ballcontrol.js(7,8): BCE0044: expecting EOF, found 'rotation'.
     
  8. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    The problem is that you've omitted a lot of the syntax for a function. Check whatever tutorial or sample script you're working from, and make sure you get all the bits - parentheses, curly brackets, etc.
     
  9. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
    #pragma strict

    var rotationSpeed = 100;

    function Update ()
    (
    var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    rigidbody.AddRelativeTorque (Vector3.back * rotation);
    ) it stil says - All compiler errors have to be fixed before you can enter gamemode.
    What should i do- plzz give an understandbile explanation
     
  10. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    This message is never going to be the only error message. (Although, it will be the most recent one, and will therefore show up at the bottom of the main Unity window.) Have you pulled up the Console window to see what the other errors shown are?
     
  11. Muzzammil

    Muzzammil

    Joined:
    Oct 24, 2014
    Posts:
    6
    Assets/ballcontrol.js(7,4): BCE0044: expecting (, found 'var'. and Assets/ballcontrol.js(7,8): BCE0044: expecting EOF, found 'rotation'.
     
  12. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    It looks like you are using the wrong braces, "(" instead of "{".
    Try this:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var rotationSpeed = 100;
    4.  
    5. function Update ()
    6. {
    7.     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    8.     rotation *= Time.deltaTime;
    9.     rigidbody.AddRelativeTorque (Vector3.back * rotation);
    10. }
     
  13. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Next time post in the correct forum section.
     
    Magiichan likes this.