I have a game where multiple instances of an enemy move towards a player in their step process. There can be as many as 50 instances on screen.
The issue is that the instances all end up in 1 big group as they follow the player. I would like to prevent them from getting more than 2 pixels of each other.
the code is as follows:
if distance_to_object(player) < 160 {
direction = ppoint_direction(x,y, player.x, player.x, player.y)
p_potential_step(x,y, player.x, true);
}
If I put a distance check of 2px in this code, the instance starts making jerky movements and spins. I would like the instance to continue following the player, but just not allow themselves to overlap.