Guest User

Untitled

a guest
May 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CamerLook : MonoBehaviour {
  6.  
  7. public float lookSenitivity = 5;
  8. public float lookSmoothDamp = 0.1f;
  9. public float xRotation;
  10. public float yRotation;
  11. public float xRotationV;
  12. public float yRotationV;
  13. public float currentXRotation;
  14. public float currentYRotation;
  15. [HideInInspector]
  16. public float lStickHorizontal;
  17. [HideInInspector]
  18. public float lStickVertical;
  19. public float lStickV;
  20. public float lStickH;
  21.  
  22.  
  23. public void Update()
  24. {
  25. lStickHorizontal = Input.GetAxis("LeftStickHorizontal");
  26. lStickVertical = Input.GetAxis("LeftStickVertical");
  27.  
  28. lStickH = lStickHorizontal;
  29. lStickV = lStickVertical;
  30.  
  31. xRotation += Input.GetAxis("LeftStickVertical") * lookSenitivity;
  32. yRotation += Input.GetAxis("LeftStickHorizontal") * lookSenitivity;
  33.  
  34. xRotation = Mathf.Clamp(xRotation, -90, 90);
  35.  
  36. currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, ref xRotationV, lookSmoothDamp);
  37. currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, ref yRotationV, lookSmoothDamp);
  38.  
  39. transform.rotation = Quaternion.Euler(xRotation, yRotation, 0f);
  40.  
  41. transform.position = transform.position;
  42. }
  43. }
Add Comment
Please, Sign In to add comment