正如标题所示,我没有使用电影,我已经编写了我自己的轨道相机脚本。当输入轴只检测到鼠标时,它工作得很好,但是当我在我的控制器上加上正确的操纵杆时,它就会摇摇欲坠。相机不断地向左移动,除非棍子被推到右边,但即使在死区,它也会不断地向左移动。其他的一切都在控制器上完美地工作,而不是相机的运动。
以下是我的相机运动脚本:
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的输入如下所示:
我真的很困惑。任何关于如何让这件事不再表现得古怪的建议,那就太好了。我不能切换到电影院,也不能切换到新的输入系统,因为我只有不到一天的时间来完成这项工作!如果我不能让它发挥作用,那也没什么大不了的,但我真的很喜欢它,因为在控制器上,这款游戏感觉很光滑。
我已经尝试过:关闭transform.LookAt(),去掉+和- to mouseX和mouseY,将target.rotation改为target.Rotate(),改变重力死区和输入管理器内的灵敏度。这些都不起作用。
发布于 2022-04-08 20:49:54
更新:我找到了解决方案。比较统一给你的两个水平和垂直轴作为基线,我发现死区实际上是问题所在。将死区设置为.19,对于游戏垫,鼠标X和鼠标Y的灵敏度为1,重力为0,解决了这个问题。
https://stackoverflow.com/questions/71802870
复制相似问题