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
0
Question by xEnOnn · Mar 27, 2013 at 12:07 AM · heightcoordinate

How can I find an object's height?

How can I find an object's height in the world coordinates? I want to use the height mainly to subtract from the object's current y-position in the world coordinate. Hence, the height has to be in the same metrics as the position vector. I tried localScale but it doesn't work correctly.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Proportion1 · Mar 27, 2013 at 12:22 AM

i know my answer sounds a bit wrong but i would add 2 emptys to the object your trying to find the height for (one on the top of it and one at the bottom). then just do

 Vector3.Distance(top, bottom);
Comment
Add comment · Show 2 · 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 xEnOnn · Mar 27, 2013 at 07:49 AM 0
Share

But this would mean I have to add 2 empties for all the objects I want to find their height. And my code would always have to check if the 2 empties are there because I could find the height.

avatar image Proportion1 · Mar 27, 2013 at 09:54 AM 0
Share

does the height of the objects change at all? if not couldn't you just have a float that represents each objects height?

avatar image
0

Answer by robertbu · Mar 27, 2013 at 03:22 PM

Take a look at Renderer.bounds. This is the bounding box in world space around your object. You should be able to get the size by:

 var height = renderer.bounds.extents.y * 2.0;


Comment
Add comment · Show 2 · 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 xEnOnn · Mar 29, 2013 at 07:41 PM 0
Share

Why am I always getting zero for using bounds.extents.y?

avatar image robertbu · Mar 29, 2013 at 08:15 PM 0
Share

Don't know. I played around and couldn't get extents.y to produce anything but the correct value, even if the object was out of the camera view and/or the renderer was turned off. Are you sure you don't have it attached to an empty game object?

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

11 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

Related Questions

Waypoint To Ignore Height & Add Smoothness 5 Answers

Is it possible to generate a high-poly spherical model from a mercator-projection heightmap? 1 Answer

Same button position in all Android devices 2 Answers

How can I get the height of a sprite? 1 Answer

Is it possible to adjust an Objects pivot without affecting any of the child objects? 1 Answer


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