Does anyone know if it is possible to detect what side of a physics object has been collided with? For example if the bottom of a square has been hit and then it does something, but NOT do anything when it is hit from any other side?
@JonoGaming00 This kind of interested me, so I thought I’d create a small example. The red circles show the contact points. This should work with any type body, but I was lazy and only used circles. The function that determines the contact points for collisions is the bod:collide function. Everything else is just standard code. I tried to make it as simple as I could so it would be easy to understand.
-- draw circles
for a,b in pairs(self.bodies) do
-- draw contact points
for c,d in pairs(self.contacts) do
for e,f in pairs(d.points) do
if c.state==BEGAN then
elseif c.state==ENDED then
@JonoGaming00 In your first post you’re talking about a square. To determine which side of a square was hit, use the x,y values of the squares corners and the x,y values from my program. That can tell you which side was hit.