Home > Software design >  Syntax Error in Unity C# (Syntax error, ',' expected) [closed]
Syntax Error in Unity C# (Syntax error, ',' expected) [closed]

Time:09-16

I can't find where I didn't put a ";". Full errors: "Assets/CameraController.cs(7,13): error CS1003: Syntax error, ',' expected" and "Assets/CameraController.cs(8,13): error CS1003: Syntax error, ',' expected"

Thanks! This is my first post here also.

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

public class CameraController : MonoBehaviour
{
    [Serialize Field] private float senseX;
    [Serialize Field] private float senseY;

    Camera cam;

    float mouseX;
    float mouseY;

    float multiplier = 0.01f;

    float xRotation;
    float yRotation;

    private void Start()
    {
        cam = GetComponentInChildren<Camera>();
    }

    private void Update()
    {
        MyInput();

        cam.transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
        transform.rotation = Quaternion.Euler(0, yRotation, 0);
    }

    void MyInput()
    {
        mouseX = Input.GetAxisRaw("Mouse X");
        mouseY = Input.GetAxisRaw("Mouse Y");

        yRotation  = mouseX * senseX * multiplier;
        xRotation -= mouseY * senseY * multiplier;

        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    }
}

CodePudding user response:

This:

[Serialize Field]

should be:

[SerializeField]
  • Related