团结,用鼠标旋转相机
我设法编写了从鼠标位置旋转相机的脚本。我
using UnityEngine;
public class RotatingTheCamera
{
[SerializeField] private float sensitivityVert;
[SerializeField] private float sensitivityHor;
[SerializeField] private float minimumVert;
[SerializeField] private float maximumVert;
private float _rotationX = 0;
private void Update()
{
if (Time.timeScale == 1)
{
_rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert);
float delta = Input.GetAxis("Mouse X") * sensitivityHor;
float rotationY = transform.localEulerAngles.y + delta;
transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
}
}
}
不知道如何在按下鼠标左按钮上旋转相机(例如拖动,但旋转)。没有那个“新输入系统”是否有可能?我现在不能使用它(我不是巫师
I have managed to write the script which rotates the camera from the position of the mouse. It is
using UnityEngine;
public class RotatingTheCamera
{
[SerializeField] private float sensitivityVert;
[SerializeField] private float sensitivityHor;
[SerializeField] private float minimumVert;
[SerializeField] private float maximumVert;
private float _rotationX = 0;
private void Update()
{
if (Time.timeScale == 1)
{
_rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert);
float delta = Input.GetAxis("Mouse X") * sensitivityHor;
float rotationY = transform.localEulerAngles.y + delta;
transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
}
}
}
I don't know how to rotate the camera basing on the pressing the left button of the mouse (like dragging, but rotating). Is it even possible without that "New Input System"? I can't use it now (I am not a sorcerer????) And is there any dependancy on Time.deltaTime?
UPD: ideone.com/pOS2gB is working
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论