Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MouseLook : MonoBehaviour {
  5.  
  6. // Speed of the rotation are public to set in Unitys editor
  7. public float speedH = 5.0f;
  8. public float speedV = 5.0f;
  9. //
  10. private float rotationX = 0.0f;
  11. private float rotationY = 0.0f;
  12. // Flip the movement of the mouse in Y or not
  13. public bool flipY = true;
  14.  
  15. // Use this for initialization
  16. void Start () { }
  17.  
  18. // This is called in every frame
  19. void Update()
  20. {
  21. rotationX += speedH * Input.GetAxis("Mouse X");
  22. rotationY -= speedV * Input.GetAxis("Mouse Y") * (flipY ? -1 : 1);
  23.  
  24. transform.eulerAngles = new Vector3(rotationY, rotationX, 0.0f);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement