# What to do after detecting OBB-OBB intersection

I'm using this code to detect intersections between two OBBs. The problem is that i don't know what to do after detecting it. I tried using a simple algorithm:

    if (collision detected) {
move character back to its position on previous frame
}


But this is not what i need, because the character is rotating and moving to certain points (usually to mouse click position). When it's close to an object with OBB and it rotates to a point, its OBB updates (the position of all OBBs corners is recalculated) and most of the time the updated OBB intersects with an object that is near, so the charecter gets stuck at its position.

How can i deal with the rotation problem or what other methods can you offer for stoping character when its OBB itersects with another?

• As soon as your moving objects rotate, it is a lot harder to use Axis-Oriented Bounding Boxes well. Also, in general it is better to check for collisions before movement(and prevent the movement from happening if there will be a collision), instead of trying to resolve overlap after movement. – Qqwy Jan 29 '13 at 20:11
• I have an idea, but i dont know how to implement it... What about finding the shortest way out of the obb? – Qualphey Jan 29 '13 at 20:18
• Maybe you can use the Euclidean distance and 2 radii of your 2 objects, so you can test spheres intersection instead of bounding boxes. Everything would be much easier. – Ivan Kuckir Jan 29 '13 at 21:45