obernardovieira

[Unity3D] First Player Camera (free move)

Oct 28th, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. static var canmove : boolean = true;
  4. private var sensitivityX : float = 10.0;
  5. private var sensitivityY : float = 10.0;
  6.  
  7. private var horz : float = 0;
  8. private var vert : float = 0;
  9.  
  10. function Start () {
  11.  
  12. }
  13.  
  14. function Update () {
  15.     if(canmove == true) {
  16.         var deltaX : float = Input.GetAxis("Mouse X") * sensitivityX;
  17.         var deltaY : float = Input.GetAxis("Mouse Y") * sensitivityY;
  18.         horz += deltaX;
  19.         vert += deltaY;
  20.         vert = Mathf.Clamp(vert, -60.0, 60.0);
  21.         transform.localEulerAngles = new Vector3(-vert, horz, 0);
  22.     }
  23. }
Add Comment
Please, Sign In to add comment