Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by captaincheerios · Jul 20, 2011 at 07:32 PM · bugmousemouse positionnormalizationmouse location

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jul 20, 2011 at 07:52 PM 0
Share

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?

avatar image DaveA · Jul 20, 2011 at 08:11 PM 0
Share

Right. Center would be .5 unless doing something non-linear, like exponential. Some code would be real helpful.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image flaviusxvii · Jul 20, 2011 at 08:34 PM 1
Share

$$anonymous$$indly notice that mousePosition is a VECTOR3!!!!!!!!!!!!.. just normalizing it will probably not behave the way you think.

avatar image Bunny83 · Jul 20, 2011 at 09:38 PM 0
Share

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.

avatar image Bunny83 · Jul 20, 2011 at 09:39 PM 0
Share

Ohh, and don't post comments as answers. There's a comment button for that. Answers should answer the question.

http://answers.unity3d.com/page/faq.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges