Collision Resolution

Started by
2 comments, last by Vile V 12 years, 11 months ago
Good day everyone,

I'm currently working on the very simple collision handling I'm going to use in my game. Its basically nothing more than rectangular collision detection and resolution. The resolution itself isn't supposed to do anything other than place the dynamic rectangles back where they're supposed to be. I've worked out two methods so far that work in the simplest of cases. Those cases are one dynamic shape hitting a single static one while moving either just vertically, or just horizontally.

In the first I normalize the velocity vector of the moving rectangle and after determining how deeply the shape penetrated the static rectangle, I multiply the height and width by the normalized vector to determine where the rectangle should be moved. This works for the simple case.
The second is simpler. I simply check which direction the rectangle was moving in and if a collision occurs I set it's X and Y to where they're supposed to go using the coordinates and size of the static rectangle. This also works for the simple case.

As you can probably see by now, problems arrise when a rectangle is moving along a surface and is given an X and a Y velocity.

My question is basically: How does the resolution for colliding rectangles work? I've found hordes of tutorials and articles online about these cases but they're applicable to far more complicated scenes. All I need are rectangles that are unable to intersect.

I hope this is clear enough and thank you for any replies,

Vile
Advertisement
No one here have a few useful tips? :)
You should track min penetration depth vector - and it will lie along vertical or horizontal axis (I assume your rectangles are AABB - i.e. their axes are parallel to world axes). In simplest case you should translate your object back by amount of that penetration depth vector (you can consider both rectangles masses and move them apart proportionally). Another way - is predict time of impact of both objects and not let them penetrate at all - for AABB it's simple enougth - you can check tutorial that I post resently - it's just about it.

You should track min penetration depth vector - and it will lie along vertical or horizontal axis (I assume your rectangles are AABB - i.e. their axes are parallel to world axes). In simplest case you should translate your object back by amount of that penetration depth vector (you can consider both rectangles masses and move them apart proportionally). Another way - is predict time of impact of both objects and not let them penetrate at all - for AABB it's simple enougth - you can check tutorial that I post resently - it's just about it.



Alright, thank you for the rapid reply. (I only just reposted 5 seconds ago O_o)
I'll take a look at your tutorial if i get stuck.

This topic is closed to new replies.

Advertisement