Search Unity

Im trying to make a platformer game and i got three errors

Discussion in 'Scripting' started by zachodacho, Oct 25, 2021.

  1. zachodacho


    Oct 25, 2021
    i got
    error CS1513: } expected
    error CS1002: ; expected
    error CS1525: Invalid expression term '}'
    what do i do
    my code is:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class player: MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    11.     }
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.         {if (input .GetKeyDown(KeyCode.Space) == true)
    17.     }// Check if space is down
    18.     {Debug.log("Space key was pressed.");
    20.     }
  2. exiguous


    Nov 21, 2010
    The compiler expects the code in a certain formal way to make sense of it (aka syntax). So you have to write it this way. When you can't spot the errors yourself I STRONGLY suggest to learn basic C# programming first. A good start is the free C# Yellow Book by Rob Miles. If you know C# it's IMO easier to dig into Unity.

    Probably someone will tell you the exact reason of the errors but even when you can fix them now and don't understand why this happens will only get you so far.

    Also a good IDE should help with such stuff.

    As a note to start your investigation. Curly braces have the meaning to put instructions together into a "block" of code. You have placed some of them in a non meaningfull way.

    Edit: Kudos for using code tags from the start ;).
    Last edited: Oct 25, 2021