I have a push out code to prevent enemies from stacking but if one enemy wants to move in front of another enemy then they will push that enemy while moving. I am looking for a way to prevent the enemies from stacking but also have a way for an enemy to move in front of another enemy. This is for a platformer.
Any help appreciated and I have searched for an answer and couldn't find one for this problem because they talked about preventing the enemies from stacking and not if there was an enemy moving past another enemy.
Example picture. If E1 stops or is moving slower and E2 is moving then E2 will push E1 towards location while moving trying to get ahead. Without a way to prevent them to stack then they will move and stop on top of each other.