svp

Hey, I’m very new to unity and coding and I’m trying to follow a tutorial but the code that I use keeps coming up with this error:

assets\scripts\Gunfire.sc(5,37): error CS1003: Syntax Error, ‘,’ expected

Idk what it means or how to fix it, I searched up lots of solutions but nothing works

heres the script:

Code (CSharp):

using UnityEngine;

[RequireComponent(typeof(CONTROLEUR))]
public class Playercontroleur : MonoBehaviour
{
[SerializeField]
private float speed = 3f

[SerializeField]
private float MouseSensitivity = 3f

private PlayerMotor motor;

private void Start()
{
motor = GetComponent();
}

private void Update()
{
float xMov = input.GetAxisRaw(“Horizontal”);
float zMov = input.GetAxisRaw(“Vertical”);

Vector3 moveHorizontal = transform.right * xMov;
Vector3 movevertical = transform.forward * zMov;

Vector3 velocity = (moveHorizontal + movevertical).normalized * speed;

motor.Move(velocity);

float yRot = input.GetAxisRaw(Mouse x);

Vector3 rotation = new Vector3(0, yRot, 0) * MouseSensitivity;
}
}

Use code tags when posting code:

It will preserve the formatting, so it’s easier for people to read. Also, it will show the line numbers so that people can find the line that is specified in the error message.

In your case, it looks like there are missing semicolons at the end of some of your variable declarations.

Go back through that tutorial again and compare exactly what you have typed to what is in the tutorial - you should see all the mistakes that you have made. You have to be exact in what you are typing, especially around spelling and capitalisation.

1 Like

Right. Also the error says it is expecting a semicolon somewhere. Sometimes the error can be misleading. However if the error tells you that you may be missing a semicolon somewhere, you may search for semicolons on the source / reference code of the tutorial and see if you have all those semicolons as well. I can already tell, the answer is no for at least two cases :slight_smile:

2 Likes