using UnityEngine;
public class Camera_rota : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
Camera.main.transform.RotateAround(new Vector3(0, 0, 0), Vector3.up, 6*Input.GetAxis("Mouse X"));
Camera.main.transform.RotateAround(new Vector3(0, 0, 0), Camera.main.transform.right,6* Input.GetAxis("Mouse Y"));
// Camera.main.transform.Translate(Camera.main.transform.forward);
}
if (Input.mouseScrollDelta.y != 0)
{
Camera.main.transform.Translate(Vector3.forward* Input.mouseScrollDelta.y*0.5f);
}
if (Input.GetMouseButton(2))
{
Camera.main.transform.Translate(-Vector3.right * Input.GetAxis("Mouse X") * 0.5f);
Camera.main.transform.Translate(-Vector3.up* Input.GetAxis("Mouse Y") * 0.5f);
// Camera.main.transform.Translate(Camera.main.transform.forward);
}
}
}
unity相机旋转放大缩小平移
最新推荐文章于 2024-04-28 22:17:04 发布