Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
3
Question by Edyvargas · Sep 05, 2014 at 04:30 AM · distance3d modelscalculateunitsmeters

How to calculate distance in meters?

Hi, i have a code to calculate the distance from one object to another, but not sure if this is in meters or what, how can i make this in meters to get an accurate calculation with all my objects?

Thanks!

....this is the code:

 var other : Transform;
     if (other) {
         var dist = Vector3.Distance(other.position, transform.position);
         print ("Distance to other: " + dist);
     }


...and if the distance its messured from the origin of the object to the origin of the other object, how about to calculate from the collide side to the collide side of the other object for example?, just guessing...perhaps the better way its using raycast?....

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by eatsleepindie · Sep 05, 2014 at 05:41 AM

The units in Unity can represent whatever you want. As long as you keep the units consistent throughout, which in your case would be 1 game unit = 1 meter, then you can use any standard of measurement you want. So, a standard Unity cube would be 1 meter x 1 meter x 1 meter, which you can use to eye measurements. So, scaling a humanoid to be about 2 cubes high would make them 2 meters high, or a bit over 6 feet.

Comment
Add comment · Show 4 · 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 Edyvargas · Sep 05, 2014 at 05:48 AM 0
Share

Great, thanks, so for games with a human scale its good to make this meter to meter calculation (makeing a model in meters to use it in Unity), and use meters as Unity units, and the distance showed by the code will be meters then.

avatar image eatsleepindie · Sep 05, 2014 at 06:07 AM 0
Share

You can use a 1 foot equals 1 game unit system if you prefer. $$anonymous$$eters is pretty standard for the industry, but as long as you kept everything consistent, you can definitely use a 1 Ft: 1 GU setup. If you were building a city game you might use 1 mile : 1 game unit, etc. If you were building a game featuring insects, it may be more sensible to use a 1 inch : 1 GU setup.

avatar image GameVortex · Sep 05, 2014 at 06:38 AM 1
Share

$$anonymous$$eep in $$anonymous$$d that the Physics in Unity assumes 1 unit = 1 meter.

avatar image tanoshimi · Sep 05, 2014 at 09:44 AM 0
Share

@eatsleepindie - I'd disagree that metres is a standard for the industry. $$anonymous$$ax defaults to inches and $$anonymous$$aya uses centimetres, for example (http://blogs.unity3d.com/2011/09/02/art-assets-best-practice-guide/). The most important thing is consistency, not just within the scale of your models, but in any physics calculations etc.

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

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cheapest way to get distance detection and triggered events. 2 Answers

Vertical Bar showing distance travelled in metre. 0 Answers

URGENT: incorrect animation distance 0 Answers

Generate randoms planets with a specific script 0 Answers

m/s "Meters" convert to au/s "Astronomical Units" 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