- Home /
box collider 2d collision
Is there any way to determine from which side (up-down-left-right) the collision happened? currently I calculate the angle between both game objects' positions and the (0, 0) point and using it, I determine the collision side, but I would like to know if there is a better way for doing this or not
on Bolt visual scripting the 2d box collider have fields to check the direction of the collision straight out of the box. So I guess on c# code you can easily do this. Check the documentation.
Can you please tell me which part of the documentation should I check?
I didn't find anything related to my question there
Sorry about my comment, I made a mistake, the 2d box collider doesn't have the direction parameter. The 2d box raycast have it.
Answer by BananaBananaGamesStudio · Feb 08 at 06:52 AM
What you are really looking for is the Physics2D.BoxCast which have the direction parameter.
https://docs.unity3d.com/ScriptReference/Physics2D.BoxCast.html