Search Unity

Question What is this error, And how do i link my player body to this skript.

Discussion in 'Scripting' started by MasterFailer, Jan 18, 2021.

  1. MasterFailer

    MasterFailer

    Joined:
    Jan 18, 2021
    Posts:
    4
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Mouselook : MonoBehaviour
    6. {
    7.  
    8.     public float mouseSensitivity = 100f;
    9.  
    10.     public Transform playerBody;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.  
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    22.         float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    23.  
    24.         playerBody.Rotate(Vector3.up * mouseX);
    25.     }
    26. }

    b3fdd951ba05ee18a9609b53da9bc658.png
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    The spelling AND capitalization of the class
    MouseLook
    must precisely match the file
    MouseLook.cs


    One of them is lowercase in the screenshot above.
     
  3. MasterFailer

    MasterFailer

    Joined:
    Jan 18, 2021
    Posts:
    4
    Thank you, its now working!
     
    Kurt-Dekker likes this.