- Home /
Shared Vector / Bounds Problem
Hey all
Say in Unity you have 2 different sized boxes, 1 large and 1 small. How can I tell if the small box is within the bounds of the large box. I can not use collision detection because I need this process to repeat a couple thousand times quickly and neither raycasting because the normals of the collider are on the opposite side. I am currently using the bounds contains function however when rotating the large box object the bounds expands to cover the diagonal angle of the rotation.
Any suggestions? Many thanks to all those that can help.
Winston
"How can I tell if the small box is within the bounds of the large box.".......
You mean within the box .. right? i.e. you DO NOT want to know if it is within the Bounding Box, you want to know if it is ACTUALLY within the BOX. Correct?
PS it's sometimes best to turn the object inside out in cases like this, then you can use ray casting.
Yes. You are correct. Do you know of any simple functions that exist and will achieve this?
Hi Winston.
(1) I understand what you're after now.
(2) Unfortunately (like many problems in real-time ga$$anonymous$$g) it's not easy by any means!
(3) Note that essentially you are trying to check if all 8 corner points are contained in the other box.
(4) In answer to your question, there is NO simple, everyday function or API available that will instantly check this for you - you have to develop the maths for your situation. To begin with this sort of field, you can look in to the classic text Real-Time Collision Detection - Christer Ericson and also Eric Lengyel 'Game $$anonymous$$athematics'.
(5) Your question is confusing because in both the title and the 2e sentence you say "the bounds of..." suggesting you are after the "Bounding Box" ("OBB") solution -- which is a totally and completely different problem set. You should click edit. Better you should probably just delete this question altogether and post a new question saying simply "does anyone have a good solution on hand for box within box calculations" and then note that you are looking for "not OBB, the actual boxes in space". You could also look on for example stack overflow and gamedev
(6) FTR I had a glance around and couldn't find any ready-to-roll solutions!
Hope this info helps you !
Answer by Rod-Green · Jan 17, 2012 at 01:33 PM
Basically what you're trying to achieve is a OBB to OBB collision detection. There should be lots of examples out there but here's a good table to help you start:
For the record Rod, it turns out he's explicitly NOT looking for an OBB solution - he wants to check the actual box against the actual box.
Your answer
Follow this Question
Related Questions
Check if player is in front of enemy? 4 Answers
Rotating Raycast with object?? 1 Answer
IsGrounded does not work 3 Answers
2D: Why aren't my raycasts conforming to their origin points? 2 Answers
Keeping the player inside the screen? 2 Answers