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:
alt text

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?

Bounds are cubes by definition. (Well, cuboids.)

Gotcha! Thanks for that, i had a funny feeling it would have been something like that, silly me =P

1 Answer

1

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).