- Home /
Getting weird results when subtracting two identical numbers
Getting weird results when subtracting one number with the same number. I thought I was gonna get 0 as the result but thats not the case. Could anyone look at the code below and please tell me whats going on?
function Update ()
{
if (Input.GetMouseButtonDown(0))
{
oldMousePos = (Input.mousePosition.x/Screen.width);
}
if(Input.GetMouseButton(0))
{
print((Input.mousePosition.x/Screen.width) - oldMousePos);
}
}
If I write it like this instead I get the exact same numbers when just clicking. If I drag the mouse around holding the key down, only "oldMousePos" will keep the same ofcourse.
print((Input.mousePosition.x/Screen.width) + " " + oldMousePos);
Also posted it on the unity forums here: http://forum.unity3d.com/threads/111155-Getting-weird-results-when-subtracting-two-identical-numbers?p=737808#post737808
Your answer
Follow this Question
Related Questions
Mouse aims at object ? 1 Answer
Getting GameObject's local mouse position relative to screen point 1 Answer
AddForce at mouse position only on table area 0 Answers
Best way to hold mouse cursor on control while activated? 0 Answers
How to make input.mousePosition Vector2 centered to middle of screen? 2 Answers