Hello,
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
sphere_mesh.bounds.Intersects(rectangle_mesh.bounds)
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:
- mathematical way to get the lines/points of the objects and see if they go through the circle
- 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.