Unity鼠标控制物体旋转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateTest : MonoBehaviour
{
private float OffsetX = 0;
private float OffsetY = 0;
public float speed = 3f;
void Start()
{
}
void Update()
{
if (Input.GetMouseButton(0))
{
OffsetX = Input.GetAxis("Mouse X");
OffsetY = Input.GetAxis("Mouse Y");
transform.Rotate(new Vector3(OffsetY, -OffsetX, 0) * speed, Space.World);
}
}
}