Search Unity

Assets\pm.cs(12,26): error CS1026: ) expected How do i fix this <<<<

Discussion in 'Getting Started' started by exploding_toaster, Jun 26, 2020.

  1. exploding_toaster

    exploding_toaster

    Joined:
    Jun 5, 2020
    Posts:
    46
    this is my code



    using UnityEngine;

    public class pm : MonoBehaviour
    {
    public Rigidbody rb;

    public int uf = 2000;

    // Update is called once per frame
    void FixedUpdate()

    //to move to the left or x
    {if(Input.GetKey("a"){rb.AddForce(0,uf,0);};

    }
    }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Your code is difficult to read the way you've written your FixedUpdate as a single line, and aren't posting it with formatting. But you had an extra ";". You don't close a method declaration with a semicolon, just the closing bracket. Your code editor will point out these errors before you even return to Unity.
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class pm : MonoBehaviour
    4. {
    5.     public Rigidbody rb;
    6.  
    7.     public int uf = 2000;
    8.  
    9.     // Update is called once per frame
    10.     void FixedUpdate()
    11.     {
    12.         //to move to the left or x
    13.         if(Input.GetKey("a")
    14.         {
    15.             rb.AddForce(0,uf,0);
    16.         }
    17.     }
    18. }
     
  3. exploding_toaster

    exploding_toaster

    Joined:
    Jun 5, 2020
    Posts:
    46
    thanks im new to unity and the forms .this realy helps alot