using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public Camera cam;
float ay;
float ax;
// Use this for initialization
void Start () {
}
void Update()
{
Vector3 fwd = cam.transform.forward;
fwd.Normalize();
if (Input.GetMouseButton(0))
{
Vector3 vaxis = Vector3.Cross(fwd, Vector3.right);
ay = -Input.GetAxis("Mouse X");
ax = -Input.GetAxis("Mouse Y");
transform.Rotate(vaxis, -Input.GetAxis("Mouse X") * 2, Space.World);
Vector3 haxis = Vector3.Cross(fwd, Vector3.up);
transform.Rotate(haxis, -Input.GetAxis("Mouse Y") * 2, Space.World);
}
}
}
鼠标旋转物体脚本
最新推荐文章于 2024-08-23 09:00:00 发布