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
2
Question by $$anonymous$$ · Aug 26, 2014 at 01:22 AM · gameobjectcolliderboundsinstantiation

Bounds is 0 when Instantiated

I have an object with a collider. It is in my scene before I press play. When I press play, I print out its bounds. Those bounds are correct.

If I Load that same object's prefab, instantiate, then print out its bounds, they come up 0. How can I get the bounds of the object's collider without having it in the scene beforehand?

This is for the object which is already in the scene, and it works:

 GameObject thing = GameObject.Find("MyThing");
 Debug.Log(thing.collider.bounds);  //prints out correct bounds

This is the broken one:

 GameObject thing = Resources.Load("MyThing") as GameObject;
 Debug.Log(thing.collider.bounds);
 //results are Center: (0.0, 5.0, 0.0), Extents: (0.0, 0.0, 0.0) which are incorrect.

How can I get the bounds after instantiation?

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 Tomer-Barkan · Aug 26, 2014 at 02:02 AM 0
Share

Are you sure the object in the scene is the exact copy of the prefab and doesn't have any local changes? Try deleting it then readding it to the scene from the prefab and see what happens.

Otherwise you might have some editor scripts changing its values, is this an NGUI object by chance? that one changes the colliders to match sprites and such.

avatar image shaneparsons · Jun 29, 2016 at 04:46 PM 1
Share

Did you ever solve this issue?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by khanouu · Dec 01, 2014 at 10:37 AM

Hi,

I fixe this issue by using gObj.SetActive( true );

Make sure your game object is active.

From the doc :

Note that this will be an empty bounding box if the collider is disabled or the game object is inactive.

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 shaneparsons · Jun 29, 2016 at 04:49 PM 0
Share

This doesn't do anything for me.

avatar image AbdulRaman · Feb 11, 2018 at 02:27 PM 0
Share

it doesn't work with. but i tried to Instantiate it and deleted it later and it worked

avatar image
1

Answer by jmasinteATI · Jul 13, 2016 at 05:53 PM

I noticed that my Extends were 0.0, 0.0, 0.0 and thought something was wrong. The game object was active. The problem was not that my extends were zero. Instead, the log was only showing one decimal place. When I added myGameObject.ToString("F4") the output changed to 0.0201, 0.0256, 0.0257, showing that indeed my extends were not zero, just small.

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

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

6 People are following this question.

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

Related Questions

Set bounds of collider added at runtime 1 Answer

Why do Instantiated GameObjects Colliders only work on player i am controlling,nothing else? 2 Answers

Why do some objects freeze on creation? 1 Answer

Struggle with vollider detection 1 Answer

Collision issues with game object 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