Making Look Fuction
I'm making a look fuction
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class MouseLooke : MonoBehaviour {
public float mouseSensitivity = 100f;
public Transform playerBody;
// Start is called before the first frame update
void Start()
{
}
// 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;
playerBody.Rotate(Vector3.up * mouseX);
}
} ` And this is the error I get:
UnassignedReferenceException: The variable playerBody of MouseLooke has not been assigned. You probably need to assign the playerBody variable of the MouseLooke script in the inspector. UnityEngine.Transform.get_localRotation () (at :0) UnityEngine.Transform.Rotate (UnityEngine.Vector3 eulers, UnityEngine.Space relativeTo) (at :0) UnityEngine.Transform.Rotate (UnityEngine.Vector3 eulers) (at :0) MouseLooke.Update () (at Assets/MouseLook.cs:24)
I have assigned it to my Main Camera which is a child of my FirstPersonPlayer, so I don't know what the problem is
Your answer
Follow this Question
Related Questions
First person controls for GoogleCardboard 2 Answers
Cant Move towards Right and Jump at same time? 2 Answers
Gyro camera control with forward and backward movement 1 Answer
how to move a gameobject based on a dice roll 1 Answer
What is the correct way to move objects relative to each other ? 1 Answer