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. Dismiss Notice

Help wanted

Discussion in 'Scripting' started by BBrilliant, Mar 20, 2021.

  1. BBrilliant

    BBrilliant

    Joined:
    Aug 22, 2020
    Posts:
    3
    I'm new to C# and am trying to make a simple platformer game. I have developed this movement script but when I try and run it, it tells me there is a compiler error, plz help. Could it be that I should be using a better visual scripting program, rn I'm using apple's text edit.

    private float speed = 2.0f;
    public GameObject character;

    void Update () {

    if (Input.GetKey(KeyCode.RightArrow)){
    transform.position += Vector3.right * speed * Time.deltaTime;
    }
    if (Input.GetKey(KeyCode.LeftArrow)){
    transform.position += Vector3.left * speed * Time.deltaTime;
    }
    }
     
  2. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    hello @BBrilliant,

    1. try to put your code into blocks it will be more readable
    Code (csharp):
    1.  
    2. put your error message, without the error message we can't help, also try to show us the line of code mentioned in the error message.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,711
    With compiler errors, you can help yourself! How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    Definitely start with some Youtube tutorials as you will save yourself a LOT of time. This is an extremely well-understood problem.

    Screen Shot 2021-03-20 at 8.11.01 AM.png
     
  4. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    Stop using TextEdit immediately. Use Visual Studio.
     
  5. Callum_Coombs

    Callum_Coombs

    Joined:
    Feb 26, 2019
    Posts:
    10
    I can't help but agree. Also, @seejayjames - I don't know why, but your post made me laugh.. Thanks for making my afternoon!
     
    seejayjames likes this.
  6. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    Heh, yeah I just can't bear to think about programmers battling an IDE that's not designed for the job. We have enough battles already!
     
    Callum_Coombs and Joe-Censored like this.