- Home /
Normalized Coordinates are Exponentially inccorect
So I have been trying to narrow out some errors in mouse track with where you click and the normalized coordinates produced. EG, the left is 0 right is 1, center is 0.9. It exponentially decreases the amount it changes. Ive made my own normalization function, but I would also like to know what i am doing wrong I hate that I'm reinventing the wheel.
And where's the code? Or should we start guessing? Also i don't quite get what you really want. Do you want "normal" normalized coordinates (0..1 linear) or do you want them to be some kind of exponential?
Right. Center would be .5 unless doing something non-linear, like exponential. Some code would be real helpful.
Answer by Bunny83 · Jul 20, 2011 at 07:54 PM
In general: normalizing is almost always the same procedure. Just divide the value by the maximum-range. If the x-coordinate goes from 0 to Screen.width just divide by Screen.width...
Answer by captaincheerios · Jul 20, 2011 at 08:14 PM
Its a property within the Input.mousePosition class so really this is the code to show me the information. Debug.Log(Input.mousePosition.normalized.ToString()); You can try Input.mosuePosition.Normalize(); however Input.mousePosition.normalized produces the same results if you use that method. I already made my own Normalized coordinate its not hard. However the unity function built into the mousePosition class is wrong. EG the reason for this post wondering if anyone else used the Unity Method to do this instead of writing their own.
$$anonymous$$indly notice that mousePosition is a VECTOR3!!!!!!!!!!!!.. just normalizing it will probably not behave the way you think.
Exactly, Normalize or notmalized will normalize the Vector3 or Vector2 to the length of 1.0 It will be always 1.0 just the direction is preserved. But that takes all 3 axis into account.
http://en.wikipedia.org/wiki/Normalized_vector
normalized will just divide each component by the length of the vector so the length becomes 1.0f
2D example: Vector2(5,7) the length of this vector is `sqrt(5² + 7²)` = 8.6023...
The normalized vector is (0.5812..., 0,8137...). The length of this vector is 1.0 so it's a normalized vector, but you want to normalize a single value. That's something different.
To get the normalized mouseposition you have to normalize each component seperately. x coord divided by Screen.width and y coord divided by Screen.height.
Ohh, and don't post comments as answers. There's a comment button for that. Answers should answer the question.
Your answer
![](https://koobas.hobune.stream/wayback/20220612151739im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mobile controls, gui mouse problem. 0 Answers
Disable mouse input and cursor in game 2 Answers
2 Bugs in my game: mouse control takes some time to load and Menu not working. 0 Answers
How to get mouse cursor position on plane and set an object's position at this point? 2 Answers
Bug for Unity 0 Answers