- Home /

# find the tangent of a box / circle collider

I am trying to find the tangent of a box collier to add an explosion force, which isn't built in to unity 2D

It should find either the ray, or the point where the tangent hits.

Any ideas on how to do that? Thanks in advance.

What do you mean by "tangent to a box collider"? A box only has tangents at its edges...

Do you mean the angle of a colliding ray to the surface plane at the point of collision? Something else?

Maybe the surface normal vector would help?

Sorry for me failing to express myself. I am trying to find (link to the referenced image)

the yellow points. The red point is the sort of viewpoint / originpoint or something

Well, you have 4 points, you should determine which points are in the range of the red dot. there might be 2 or 3. If there is 2, then you have your points, if 3, the one with the biggest angle combined with the red dot gives you the answer.

to find which of them are in the range, you can put empty gameobjects just a little away from the corner, 0.1 for example and cast a ray towards the red dot and see if it hits the square object. that's what I would do.

But I'm sure someone else would give you simpler answer.

thanks koray, but i don`t know how to determine the two points... I have tried raycasting before, but too many rays slow down the game extremly

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.