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

Scripting problem

Discussion in 'Editor & General Support' started by Neo_maister, May 22, 2015.

  1. Neo_maister

    Neo_maister

    Joined:
    Apr 16, 2015
    Posts:
    14
    Code (JavaScript):
    1. #pragma strict
    2. var looksensitivity : float = 5;
    3. var yRotation : float;
    4. var xRotation ; float;
    5. var CurrentXRotation : float;
    6. var current YRotation : float;
    7. var yRotationV : float;
    8. var xRotationV : float;
    9. var lookSmoothness : float = 0.1;
    10.  
    11. function Update ()
    12. {
    13.   yRotation += Input.GetAxis("Mouse x") * looksensitivity;
    14.   xRotation -= Input.GetAxis("Mouse y") * looksensitivity;
    15.  
    16.   Transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
    17. }
    is there something wrong when i checked the compile errors it says insert a semicolon at the end and also expecting EOF instead found YRotation

    how to solve this?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    line 6, you have a space in your variable name. Also in future you will have better look with the Scripting part of the Forum for these types of question ;)
     
  3. Neo_maister

    Neo_maister

    Joined:
    Apr 16, 2015
    Posts:
    14
    but when i fix it the console now say new errors :
    -BCE0051: Operator '+' cannot be used with a left hand side of type 'Object' and a right hand side of type 'float'.
    -BCE0034: Expressions in statements must only be executed for their side-effects.
     
  4. Gnatty

    Gnatty

    Joined:
    May 17, 2012
    Posts:
    77
    Line 4, change the first semi-colon to a colon, so it reads ...
    Code (JavaScript):
    1. var xRotation : float;
     
    karl_jones likes this.
  5. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    line 4, you have a semicolon instead of a colon in the middle. Wondering how don't you get this syntax errors highlighted in your code editor.
     
  6. Neo_maister

    Neo_maister

    Joined:
    Apr 16, 2015
    Posts:
    14
    maybe its highligted but im a careless guy lol XD
     
  7. Neo_maister

    Neo_maister

    Joined:
    Apr 16, 2015
    Posts:
    14
    Code (JavaScript):
    1.  #pragma strict
    2.     var looksensitivity : float = 5;
    3.     var yRotation : float;
    4.     var xRotation : float;
    5.     var CurrentXRotation : float;
    6.     var currentYRotation : float;
    7.     var yRotationV : float;
    8.     var xRotationV : float;
    9.     var lookSmoothness : float = 0.1;
    10.    
    11.     function Update ()
    12.     {
    13.       yRotation += Input.GetAxis("Mouse X") * looksensitivity;
    14.       xRotation -= Input.GetAxis("Mouse Y") * looksensitivity;
    15.    
    16.       CurrentXRotation = Mathf.SmoothDamp(CurrentXRotation, xRotationV ,lookSmoothness);
    17.       CurrentYRotation = Mathf.SmoothDamp(CurrentYRotation, yRotationV ,lookSmoothness);
    18.      
    19.       transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
    20.     }
    21.  
    Ive added some new codes but this time this error in console comes up:
    - BCE0023: No appropriate version of 'UnityEngine.Mathf.SmoothDamp' for the argument list '(float, float, float)' was found.
    -BCE0005: Unknown identifier: 'CurrentYRotation'.
     
  8. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    karl_jones likes this.