Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class camMouseLook : MonoBehaviour
  6. {
  7. Vector2 mouseLook;
  8. Vector2 smoothV;
  9. public float sensitivity = 5.0f;
  10. public float smoothing = 2.0f;
  11. public GameObject Character;
  12.  
  13. void Uptade()
  14. {
  15. var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
  16.  
  17. md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
  18. smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
  19. smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
  20. mouseLook += smoothV;
  21.  
  22. transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
  23. Character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, Character.transform.up);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement