how do i get collision objects?

i did try looking on youtube, every youtuber makes sure to avoid this issue by making their explosion script as useless as it can get.

Basically, i need to check if object is visible or reachable. Explosion happens, i need to know if the explosion will hit the object and if it does, do damage.
I have same problem with detecting targets.

@Hellium the images show why raycast isn’t enough. The blue represents raycast

Here is one way to do it: I’m assuming you are working in 2D, [edit] no this won’t work in 3D because you have to take Perspective into account so disregard this statemet: but this also works in 3D[/edit]. Rather than multiple Raycasts, do Physics2D.BoxCast the size of the enemy from player to enemy and get any collisions.

Any hits will tell you the enemy is at least partially hidden by an obstacle.

You then need to determine whether or not the overlap of the BoxCast bounds at the position of the obstacle is completely within the bounds of the obstacle - indicating that obstacle hides the enemy completely - or only partially within - indicating that some part of the object can be seen.

Getting bounds of objects and checking them for overlap is fairly simple to do, and I’m not talking about the actual Bounds Class object that is accessible through an object’s mesh, though you could possibly employ that. You can use objects scale values combined with the position to create your own bounds.

maybe i can get closest point of all tank colliders to the explosion and shoot raycasts in that dirrection? in most cases that system would work, but there would still be odd angle cases