- Home /
bound.Intersects returning true when false
I'm having some issues with a bounds.Intersects check. I'm generating a mesh based on the frustum so there is a cube going straight down the center of the screen in proportion based on the distance it is from the camera. On the scene i have plane objects which i can press on and drag around the screen. For example i have a plane at -24 on the z axis with a sphere collider and when i drag it around it does an Intersects check to see if it is within the cube it returns true even though you can clearly see that they do not intersect:
With another example example, this time i have another plane but further from the camera position, this collider is a capsule collider and it perfectly returns true/false if the colliders are intersecting.
And i missing something? Is there an issue with doing a check with a sphere collider or something to do with the distance from the camera? Or the shape of the bounds im checking? Are the bounds just checked as a cube? Or does it actually check the real mesh?
Gotcha! Thanks for that, i had a funny feeling it would have been something like that, silly me =P
Answer by Default117 · Feb 20, 2012 at 05:57 AM
I ended up checking where i click, taking that objects' z depth and using it as a "cut height". Using this height relative to the position of the mesh im checking against, i could use this formula:
Vector2 cut_side = (cut_height/total_height)*(bottom_side) - top_side) + top_side;
This formula returns the width and length at a given height, so now i can use those values to determine the 4 vertices of slice of the mesh i just clicked on.
Since i know what the length and width is for the top and bottom squares of the mesh i turned this data into a Rect and then did a check against that to see if the object is within the rect (Collision).
Your answer
![](https://koobas.hobune.stream/wayback/20220613064244im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
3d Text how do you autofit to a fixed space 0 Answers
How to check the place before drop the object 1 Answer
collider bounds intersect but than for a UI button element 0 Answers
Problem with checking for intersection between two rotated objects 3 Answers
Collider2d.bounds.Intersects not detecting intersection 1 Answer