如何使用游戏手柄输入或鼠标输入进行相机转动?(没有电影院,使用旧的输入系统)



正如标题所示,我没有使用电影机器,并且已经编写了我自己的轨道相机脚本。当输入轴只检测鼠标时,它工作得很好,但当我在控制器上添加对右操纵杆的检测时,它就会变得很不稳定。除非将操纵杆向右推,否则相机会持续向左移动,但即使在死区中,它也会持续向左移。其他一切都在控制器上运行得很好,只是相机运动不好。

以下是我的相机运动脚本:

transform.LookAt(target); //make sure we're looking at the target. TODO: make it lag a little bit!
if (canControlCam)  //may i?
{
mouseX += Input.GetAxis("Mouse X") * rotSpeed;  //get the x and y values of the mouse, rotSpeed is sensitivity. TODO: change this to work with either mouse or gamepad
mouseY -= Input.GetAxis("Mouse Y") * rotSpeed;  
mouseY = Mathf.Clamp(mouseY, -60, 50);  //clamp the mouse so it doesn't freak out. Update: it's freaking out anyway. Could this be the issue?

if (!moving)    //if we are stationary, allow movement around the player.
{
target.rotation = Quaternion.Euler(mouseY, mouseX, 0);
}
else //if we're moving, make the player rotate with the camera. Feels much more natural
{
target.rotation = Quaternion.Euler(mouseY, mouseX, 0);
player.rotation = Quaternion.Lerp(player.rotation, Quaternion.Euler(0, mouseX, 0), time);
//player.rotation = Quaternion.Euler(0, mouseX, 0);
}
}

正如你所看到的,它非常简单。现在,我有了";鼠标X";以及";鼠标Y";轴实现了两次,就像我对其他输入所做的那样:一次用于MnK,一次用于游戏板。两者都不能正常工作。

以下是项目经理中鼠标Y的输入:

鼠标Y的鼠标输入鼠标Y 的控制器输入

我真的很困惑。任何关于如何让这件事不再显得古怪的建议,都将是美妙的。我不能切换到电影机,也不能切换到新的输入系统,因为在我出现之前,我只有不到一天的时间来完成这项工作!如果我不能让它发挥作用,那也没什么大不了的,但我真的很喜欢它,因为游戏在控制器上感觉很流畅。

我尝试过的事情:关闭转换。LookAt((,将+和-改为mouseX和mouseY,将target.rrotation改为target。Rotate((而不是eulers,更改输入管理器内的重力死区和灵敏度。这些都没有奏效。

更新:我找到了解决方案。比较统一作为基线的两个水平和垂直轴,我发现死区实际上是问题所在。将游戏板鼠标X和鼠标Y的死区设置为.19,灵敏度设置为1,重力设置为0,解决了这个问题。

最新更新