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 Hugmungus · Sep 12, 2012 at 09:51 PM · meshproceduralphysics.overlapsphere

Is there a physics.OverlapCube?

Hi all, first post on the forms here. I've been working with procedural mesh creation and texturing in order to create a Voxel based world in Unity, and I've been following the advice of this blog post. Anyway, the reason for my question is that I would like to be able to grab all of the meshes within a space, say a 5 X 5 X 5 cube, and store those values in an array in order to combine them into one mesh. OverlapSphere does a wonderful job of this, but uses a sphere which leaves out the meshes in the corners. If anyone knows of a build-in function I can use for this, or another method that would work, it would be much appreciated. Thanks in advance for the help!!!

Link for blog-post: http://www.sauropodstudio.com/how-to-make-a-voxel-base-game-in-unity/

Comment
Add comment · Show 1
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 huulong · Jan 30, 2016 at 06:22 PM 0
Share

This appeared in some version of Unity since you posted:

http://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html

And its NonAlloc counterpart.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by DaveA · Sep 12, 2012 at 10:19 PM

Probably a better way, but off the top: 1. Create a BoxCollider, set size position, check for collisions 2. Use an OverlapSphere, but set the radius to the diagonal length of the cube (eg 5 * 2^.3333) (cube-root of 2 times 5) to get a sphere's-worth of objects, then cull those by checking their bounds http://docs.unity3d.com/Documentation/ScriptReference/Renderer-bounds.html

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 Hugmungus · Sep 13, 2012 at 07:47 PM 0
Share

Thanks Dave, I was leaning toward the BoxCollider myself, but was trying to figure out how to store all or the collisions in an array. I think I'm going to have each object that collides with the collider add itself to the array as opposed to having the collider add all objects that collide with it to the array. We'll see how it goes.

avatar image maesla · Feb 05, 2013 at 11:16 AM 0
Share

I have the same problem. What solution did you finally find?

Thank you

avatar image Bunny83 · Feb 05, 2013 at 12:30 PM 0
Share

OverlapSphere does even check against the bounding box. Using Bounds.Intersects can be used to actually test AABB against AABB.

avatar image maesla · Feb 05, 2013 at 01:52 PM 0
Share

Yes finally I did that way. I used Sphere Overlap and then I used a bounds and I checked it with Bounds.Intersects.

It seems it works fine. Thanks

avatar image
1

Answer by vanarebane · Apr 28, 2016 at 05:17 AM

There is now a OverLapBox. I googled and found your problem and then I tried to find it in API and found the OverlapBox.

 Vector3 m_ExplosionBox = new Vector3(0.25f, 0.5f);
 
 Collider[] colliders = Physics.OverlapBox (transform.position, m_ExplosionBox, transform.rotation, m_Mask);

More here: http://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html

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

15 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

Related Questions

Determine whether or not model is "inside out" 2 Answers

Combining meshes (different materials) together for rotation/translation 1 Answer

Custom Mesh UV Problem 1 Answer

Mesh return vs out Mesh 2 Answers

Strange shading on procedural mesh 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