Detecting which side of object collision occurred

cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Detecting which side of object collision occurred

Post by cobolt_dink »

I'm overriding the collision callback and have a rigid body and kinematic object colliding. But I want to bounce the kinematic object away in a Breakout style instead of real physics. So I need to know what side of the object I hit so I can update the kinematic objects forward vector. For example if I hit the left or right side then I flip the sign on the x value and if its the top or bottome I flip the z value.
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: Detecting which side of object collision occurred

Post by cobolt_dink »

I'll just bump this once. The only way I could figure out is getting the positions of each object in the collision callback and checking the individual x, y, z coordinates of the objects. Was hoping maybe there was something cleaner.
ryanjuckett
Posts: 13
Joined: Tue Mar 11, 2008 9:04 am

Re: Detecting which side of object collision occurred

Post by ryanjuckett »

The contact point supplied to the callback with contain a collision normal (i think on the surface of the second object). If I follow you correctly, you should just be able to reflect across the collision normal. You could even just check the value of the normal for being close to a world axis is everything is axis aligned to figure out which side you hit.