Collision detection happy little accidents

I added collision detection to the game, so now all the characters test against each other and the inanimate objects. The results are not pretty.

The problem here is not collision detection, which is being done properly. The problem is collision resolution. Right now I’m treating all objects in the game as totally inelastic, which means that when they collide their velocities are swapped. That’s simple. The problem is that I also need to push them far enough away from each other that they don’t just collide again next frame, and swap their velocities back, which will cause them to get stuck forever. We can clearly see that happening to the hunters at the end there.

Right now I’m just going with the hackish “change velocity appropriately, then move them by double what we would normally move them by according to their velocity”, which kind of works, but has those cases, like with the hunters, where we get trapped in the infinite loop. What I really need to do, is calculate the shortest path to not colliding, then move them a bit.

This entry was posted in Monochrome, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s