Help with "Assets/MouseLook.cs(23,44): error CS1003: Syntax error, ',' expected"

I am following a tutorial by Brackeys (Youtube) with link

I was around 9 minutes in and I copied it word for word and it still doesn’t work

In my console it says:
Assets/MouseLook.cs(23,44): error CS1003: Syntax error, ‘,’ expected

Assets/MouseLook.cs(24,44): error CS1003: Syntax error, ‘,’ expected

When it is with quotes around the ‘Mouse X’ and the ‘Mouse Y’ it doesn’t work.

Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis(Mouse X) * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis(Mouse Y) * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, of, of);
playerBody.Rotate(Vector3.up * mouseX);

Hi,
Not sure what you mean with that it does not work. But you could check out this page: Unity - Scripting API: Input.GetAxis, according to that you should not use Time.deltatime when reading using mouse data for the GetAxis().

Best regards

When I said that it didn’t work, It says that there is a syntax error as there are unexpected qoutes there and still expected commas.

P.S. Does your last response mean that I just take the Time.deltatime out?

Mouse X is supposed to be a string, and as such, it needs to be in double quotes (same for Mouse Y):

float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;

Additionally, you typed “of” where you want “0f” on this line:

transform.localRotation = Quaternion.Euler(xRotation, of, of);
1 Like

I have the same problem

Well, then read through what others said about how to fix it.

2 Likes