Unityの簡易カメラの画角はマウスの回転に合わせて回転します

ナンセンスではありません。コードを直接アップロードし、カメラに直接ドラッグして使用してください。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Camerafollow : MonoBehaviour
{
    
    
    public float moveSpeed;
    // Start is called before the first frame update
    void Start()
    {
    
    
        moveSpeed = 60f; //移动速度
    }

    // Update is called once per frame
    void Update()
    {
    
    
        Vector3 angle = Vector3.zero;

        angle.x = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * moveSpeed * Time.deltaTime;
        angle.y = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * moveSpeed * Time.deltaTime;

        transform.localEulerAngles = angle;

      

    }
}

おすすめ

転載: blog.csdn.net/weixin_44277869/article/details/108976233