Does it take a ton of math to figure out when a circle and square collide? I could use two collision bodies for each unit, a circle and a square, I could then use the square for when a unit collides with a rectangle obstacle and the circle to collide against other units. It’s a solution but if a unit collides with a rectangle obstacle it would get stuck in place. It would be nice to have a sliding effect against the rectangle obstacle walls when other circles are pushing from the sideways. The rectangle obstacle should cause a bounce back for that to happen.
Square circle collision
Calin said:
Does it take a ton of math to figure out when a circle and square collide?
No.
For objects motion you also might want to consider using swept tests (which might be necessary to properly implement sliding effects).
My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com
@Calin See if this post helps:
If I understand your desire to have a sliding effect, it's not too hard. Consider a circle approaching a wall at a 45° Angle. When they collide, you don't want the circle to stop, but move along the wall..
You need to break down the circle's velocity into two components. The first component would be in the direction that's orthogonal to the wall. If you subtract this component from the circle's velocity, you're left with the direction that goes along the wall.