- Home /
How to get rid of jumpy collisions?
Hi, I am currently attempting to implement a top-down style game and am trying to do collision detection that doesn't rely on Unity Physics. The problem I am currently having is that my enemies do collide with each other and do not clip through, but they have a very jumpy movement as they attempt to push through each other. I know that when I use Unity Physics to deal with collisions, this problem does not occur. Does anyone know how to deal with this so that I do not have to jump back to Unity Physics?
PS: The current behavior of the enemies is a very simple algorithm. They just rotate towards the player every Update, and translate a set distance towards them. The problem is that I do not know how to prevent them from moving once a collision has been detected without just stopping any further behavior.
Answer by robertbu · Jan 14, 2013 at 08:47 PM
From your description I'm envisioning a horde of zombies closing in on our hapless hero. Without a better description or some posted source, I don’t know how you are doing your collision detection. But since you are doing your own detection, you could test a move first to see if it will cause a collision. You never allow a move that would cause two enemies to collide. For each enemy in turn, if a forward move causes a collision, try a slight move right, then a slight move left, then a slight move back, then stand still. Sooner or later, either the enemy “in front” will move out of the way or the enemy in back will move around the enemy.