My script gives errors

I wrote this script watching a video (im a total beginner) which is for first person movements, if someone needs it i will link it. When i run my code, i get these errors:


Here is the code, i didnt copy-paste from a comment or something, i wrote it by watching:

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

public class MouseLook : MonoBehaviour
{
    public float mouseSensitivity = 100f;
    float xRotation = 0f;
    public Transform playerBody;
    // 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;
      playerBody.Rotate(Vector3.up * mouseX);
     

      xRotation = Mathf.Clamp(xRotation, 90f, -90f);
      Transform.localRotation = Quanternion.Euler(xRotation, 0f, 0f);
    }
}

Im still learning, so if possible can you explain why it happens so that i dont mess it up again

I believe that you just have an error in your spelling of quaternion. there is no ‘n’ in the first part of the word. (quant should be quat)

1 Like

Oh, that means i just didnt see it right. Thank you, tomorrow i will try and tell you. From my opinion the other error seems like is caused from something else, do you know what?

no, I’m sorry, I’m not sure what. I have not used quaternions a lot and only caught the typo. I’m not terribly familiar with them otherwise.

1 Like

It’s both a typo with “Quanternion” and “Transform”.

“Quanternion” just needs that extra ‘n’ removed.

“Transform” should start with a lowercase “t” in order to reference the Transform component attached to the GameObject, because you are currently referencing the Transform class itself.

1 Like

Ok thank you i will try!

It works! Thank you!

It works! Thank you so much!