Search Unity

Why do I keep getting an error?

Discussion in 'Scripting' started by destructavic, Mar 20, 2018.

  1. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    Sorry im such a noob. Please help.

    private Rigidbody rb;
    void Start()
    {
    rb = GetComponent<Rigidbody>()

    }
    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

    rb.AddForce(movement);
     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    I only briefly glanced as ive seen far too many threads today without code tags used... :)

    Perhaps the force being added isnt enough to move the rb?

    Just a thought. Im tired. No code tags... tsk tsk.

    Oh.. you're looking for an error? ( again... tired. Sleep time for me) Try the console. It will tell you. You didnt tell us the error the console printed out.

    Could be the lack of that last }

    Lol.
     
    Last edited: Mar 20, 2018
  3. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    Error CS1002 CS1513 CS1513

    Sorry i'm such a noob. This is literally my first script and I keep smashing my head against the wall
     
  4. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    There would definitely be more info then that in console.

    Go to windows / console menu.

    What does it tell you...

    Sorry, i literally barely looked at code, it seemed ok other then the missing } at the end.

    But use the Insert / Code Tag option in forum post.
     
  5. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    Oh. You are also missing a semi colon in Start ()

    GetComponent<Rigidbody>();
     
  6. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    your suggestion removed one of my errors :)
    hmmm, when i click the window tab i'm not seeing a console menu(Microsoft visual studio)

    insert code tag?

    Thanks again for the assistance btw.
     
  7. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    I meant in unity

    Did you fix the semi colon error?
     
  8. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    Code Tags are option found in forum post options...

    Code (CSharp):
    1. private Rigidbody rb;
    2.  
    3. void Start()
    4. {
    5.      rb = GetComponent<Rigidbody>();
    6. }
    7.  
    8. void FixedUpdate ()
    9. {
    10.     float moveHorizontal = Input.GetAxis("Horizontal");
    11.  
    12.     float moveVertical = Input.GetAxis("Vertical");
    13.  
    14.     Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    15.  
    16.     rb.AddForce(movement);
    17. }
     
  9. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    yes i did, it removed an error. Now there's one left.

    Okay so unity is saying four errors
    editor layout can not be fully loaded
    request error(unity editor)
    request error(unity editor)
    assets/scripts CS1525 unexpected symbol
     
  10. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    I see... sorry for the noobness lol
     
  11. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    Is your script really missing the last curly bracket? } lol.

    Anyways sorry, just wiped. But now the codes a lil easier to decipher. Check out the poster options for next time.
     
  12. destructavic

    destructavic

    Joined:
    Mar 1, 2018
    Posts:
    15
    whoa... that just fixed the problem... ive literally spent hours on this... i feel like an idiot... thanks for all your help man seriously
     
    Homicide likes this.
  13. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    We all been there. Enjoy :)