[英]UnassignedReferenceException in camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLock : MonoBehaviour
{
public float mouseSensetivity = 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") * mouseSensetivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensetivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
我真的沒有看到任何問題,你可以看到它只在一個對象上的代碼,它是我從教程中得到的相機。
您是否將 playerBody 變換從層次結構拖到 MouseLock 組件中的 playerBody 變量槽中?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.