我是 Unity 脚本的新手,我正在尝试制作 ThirdPersonCamera,因此按照本教程,他可以正确地上下左右移动鼠标
使用的脚本是
posY += Input.GetAxis("Mouse X") * mouseSensitivity;
posX -= Input.GetAxis("Mouse Y") * mouseSensitivity;
// mouseSensitivity can be changed
Vector3 targetRotation = new Vector3(posX, posY);
transform.eulerAngles = targetRotation;
Run Code Online (Sandbox Code Playgroud)
由于新的输入系统,使用Input.GetAxis("Mouse X")会引发InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings错误。
所以我尝试使用
private PlayerInputMovement inputCamera;
void Awake(){
inputCamera = new PlayerInputMovement();
inputCamera.Player.Camera.performed += context => cameraInput = context.ReadValue<Vector2>(); …Run Code Online (Sandbox Code Playgroud)