Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class MouseDeltaCheck : MonoBehaviour
  2. {
  3. public Vector2 screenPos;
  4. public Vector2 positionDelta;
  5. public Vector2 inputDelta;
  6. public Vector2 ratio;
  7.  
  8. void Update() {
  9. Vector2 newScreenPos = Input.mousePosition;
  10.  
  11. positionDelta = newScreenPos - screenPos;
  12.  
  13. inputDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
  14.  
  15. if(inputDelta.x != 0f)
  16. ratio.x = positionDelta.x / inputDelta.x;
  17. if (inputDelta.y != 0f)
  18. ratio.y = positionDelta.y / inputDelta.y;
  19.  
  20. screenPos = newScreenPos;
  21. }
  22. }
  23.  
  24. {Change in Pixel Position} * {Axis Sensitivity} * {OS Scaling Factor} * 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement