Problem with getting colliding objects

I have a mine which damages in a radius.
When I click a button the mine explodes and I have to check what is colliding with the mine radius.

I tried making a Primitive.Sphere with the radius of the blast.
But i can’t make the check if that sphere collides with another objects.

I tried looping through the other primitive objects and try
and my_sphere.renderer.bounds.Intersects(my_rectangle.renderer.bounds)
but these methods don’t work very accurately because the bounding box is not rotating (it just expands and mesh.bounds is in local space and doesn’t rotate too)

I dont want to use OnCollisionEnter and OnCollisionExit or triggers. I want to make it in utilities function.

I just want to check if there is an object touching the blast radius.

In my opinion there are two options:

  1. mathematical way to get the lines/points of the objects and see if they go through the circle
  2. make some kind of intersections of the primitive objects

I preffer the mathematical way because i can make the checks even on the server (where i don’t have GameObjects only values) and then the server can make the check and return the damaged units.
But the problem with the mathematical way is that the rectangles rotate…

The idea I have is to take the sides of the rectangle and rotate them the right way and
make intersection between circle and lines (and line with line)

But I am not good at math and I can’t do it.
And i really think that the mathematical way is the way to go.

Has anyone done such mathematical intersection scripts ?

Any help would be apreciated.

You talk about rectangle and circle, so I cannot tell if this is 3D or 2D. The typical 3D solution is to use Physics.OverlapSphere().

The function will return a list of colliders that are within a specified radius of a specified point.

For 2D, there is Physics.OverlapCircleAll().

An idea that i have is:
Get the points calculated from the center

poin1 = posision.z + height/2 , position.x - width/2
and so on…

(every Y coordinate is 0 to check only 2D coordinates)

and then rotate the points around the center with the function from this post:
The Post

But now comes the question how to check if lines between the points intersect another line or circle

I solved it!
So i get the coordinates ot he cornes of the rectangle (as told above)
And then i make Rays from one point to the other
And the rays have distance equal to the distance between the points

And after that i check if those rays intersect another object.