Error cs1002: ; expected. I need some help please

I understand I’m missing a semicolon somewhere? I can’t figure out which line is missing it though. any help is appreciated. also idk how to copy the line numbers im sorry.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
//public or private reference
// data type (int, float, bool, string)
//every variable has a name
//optional value assigned
[SerializeField,]
private float _speed = 3.5f;
}

// Start is called before the first frame update
void Start()
{
// Take the current position = new position (0, 0, 0,)
transform.position = new Vector3(0, 0, 0);
}

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

float horizontalInput = Input.GetAxis(“Horizontal”);
float verticalInput = Input.GetAxis(“Vertical”);
// new Vector3(-5, 0, 0)

//transform.Translate(Vector3.right * horizontalInput * _speed * Time.deltaTime);
// transform.Translate(Vector3.up * verticalInput * _speed * Time.deltaTime);
Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);
transform.Translate(direction * _speed * Time.deltaTime);

//if player position on the y is greater than 0
//y position = 0
// else if position on the y is less than -3.8f
//y pos = 3.8f

if (transform.position.y >= 0)
{
transform.position = new Vector3(transform.position.x, 0, 0);
}
else if (transform.position.y <= -3.8f)
{
transform.position = new Vector3(transform.position.x, -3.8f, 0);

}

//if player on the x > 11
//x pos = 11
//else if player on the z is less than -11
//x pos = 11

if (transform.position.x > 11.3f)
{
transform.position = new Vector3(-11.3f, transform.position.y, 0);
}
else if (transform.position.x < -11.3f)
{
transform.position = new Vector3(11.3f, transform.position.y, 0);
}

You’re just making typing mistakes. Go fix them. Here’s how:

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

  1. Welcome to the Unity forum :slight_smile:

  2. Please go read this article here: Game Dev Things - Unity tutorials and in depth game-dev articles.
    It will explain how to decipher those erros you see.

If you still have questions afterwards feel free to come back here and ask again.

Your braces are rioting and are all over the place.

I’ve restored law and order:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
//public or private reference
// data type (int, float, bool, string)
//every variable has a name
//optional value assigned
[SerializeField,]
private float _speed = 3.5f;


// Start is called before the first frame update
    void Start()
    {
        // Take the current position = new position (0, 0, 0,)
        transform.position = new Vector3(0, 0, 0);
    }

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

        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput = Input.GetAxis("Vertical");
    // new Vector3(-5, 0, 0)

    //transform.Translate(Vector3.right * horizontalInput * _speed * Time.deltaTime);
    // transform.Translate(Vector3.up * verticalInput * _speed * Time.deltaTime);
        Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);
        transform.Translate(direction * _speed * Time.deltaTime);

    //if player position on the y is greater than 0
    //y position = 0
    // else if position on the y is less than -3.8f
    //y pos = 3.8f

        if (transform.position.y >= 0)
        {
            transform.position = new Vector3(transform.position.x, 0, 0);
        }
        else if (transform.position.y <= -3.8f)
        {
            transform.position = new Vector3(transform.position.x, -3.8f, 0);
        }

    //if player on the x > 11
    //x pos = 11
    //else if player on the z is less than -11
    //x pos = 11

        if (transform.position.x > 11.3f)
        {
            transform.position = new Vector3(-11.3f, transform.position.y, 0);
        }
        else if (transform.position.x < -11.3f)
        {
            transform.position = new Vector3(11.3f, transform.position.y, 0);
        }


    }

}