RotateCamera.cs 617 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RotateCamera : MonoBehaviour {
  5. float MouseRotateSpeed = 80f;
  6. // Use this for initialization
  7. void Start () {
  8. }
  9. // Update is called once per frame
  10. void Update () {
  11. float y = Input.GetAxis("Mouse X") * MouseRotateSpeed * Time.deltaTime;
  12. float x = Input.GetAxis("Mouse Y") * MouseRotateSpeed * Time.deltaTime;
  13. transform.Rotate(-x, y, 0);
  14. Vector3 Angles = Camera.main.transform.eulerAngles;
  15. transform.eulerAngles = new Vector3(Angles.x, Angles.y, 0);
  16. }
  17. }