未分配引用相机中的异常


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);
}
}

我真的没有看到任何问题,你可以看到它只在一个对象上的代码,这是我从教程中得到的相机。

控制台

您是否将播放器主体转换从层次结构拖动到 MouseLock 组件中的玩家主体变量槽中?

相关内容

  • 没有找到相关文章

最新更新