r/UnityHelp • • Jun 17 '21

PROGRAMMING Assets\Scripts\PlayerController.cs(31,2): error CS1513: } expected 📷

this error keeps coming up, idk why

heres my code

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour

{

private Rigidbody rb;

private float MovementX;

private float MovementY;

// Start is called before the first frame update

void Start()

{

rb = GetComponent<Rigidbody>();

}

void OnMove(InputValue MovementValue)

{

{ Vector2 movementVector = MovementValue.Get<Vector2>();

movementX = MovementVector.X;

movementY = MovementVector.Y;

}

void FixedUpdate()

{ Vector3 Movement = new Vector3(MovementX, 0.0f, MovementY);

{

rb.AddForce(Movement);

}

}

3 Upvotes

1 comment sorted by

View all comments

1

u/Feuerkeule Jun 18 '21

Heyho!

Just as the error message displays "} expected", if this is the entire script, I count 6 open brackets( { ) but only 4 closed brackets( } ). I also noticed that in the two methods other than Start() you open with two curly brackets instead of one. Might be some habit from another language you are used to that makes you write an additional open bracket at the beginning.

Not to talk down to you, I just do not know your programming knowledge, the amount of open and closed brackets should generally be the same. I think even exclusively, but am a junior dev as well and unsure of any special cases for C#.

Best regards!