- Home /
Is there an easy way to find out exactly where a game object was hit in a collision (top, bottom, upper left, etc.)?
I'm using vector2 lerp to move a game object about, but when it collides with other objects, I would like it to stop before it passes through them. So, I was thinking that the best solution would be to find collision contact points and test them against the objects position. I'm not sure if this is the best way to do it, if anybody knows of another way to do this, I would be stoked to here them out..
Thanks in advance
i think the way you wanna do it is good. Get the contacts points and look at their localposition in the gameobject. So you can guess what is their position.
I agree with @moha about contact points. I'd just add that you can always use collision.gameObject.transform to find the position of the object that you hit. Comparing that to the transform of the target object allows you to quickly tell their relative positions.
Your answer
![](https://koobas.hobune.stream/wayback/20220613104558im_/https://answers.unity.com/themes/thub/images/avi.jpg)