团结,用鼠标旋转相机

发布于 2025-02-07 10:13:05 字数 975 浏览 1 评论 0原文

我设法编写了从鼠标位置旋转相机的脚本。我

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文