Question by
jagroopsingh0074 · Oct 07, 2018 at 02:04 AM ·
2d collision
how to destroy collider from one side collision not from other sides.,how to destroy collider from one side and dont do anything from other sides
i want to destroy a game object to destory when hit from below but if jump on that object than do nothing.
Comment
Answer by LeonardNS · Oct 07, 2018 at 11:31 PM
You should look into the normal vector of a collision. The normal vector is basically the direction the object experiences force from. When hitting an object from below, naturally the force on your character is from above, which means the y-coordinate of the normal vector the player is experiencing is negative. Likewise, when you hit an object from above, the force experienced by your character is from below, which means the y-coordinate of the normal vector is positive.
Documentation on normals