enemies overlapping? (GMS2) (SOLVED)

KPJ

Member
Hi all. I have an issue in my top down game where enemies move toward the player. When there is more than one enemy, the enemies overlap and look like one. Here is my code:
Code:
//Enemy Create
grid = mp_grid_create(0, 0, room_width / 32, room_height /32, 32, 32);
mp_grid_add_instances(grid, oWall, false);
path = path_add();

//Enemy Step
mp_grid_path(grid, path, x, y, placeofinterestx, placeofinteresty, true);
path_start(path, enemyspd, path_action_stop, true);
Anyone know how to fix this? Thanks a lot!
 
This is a very common question. Since your code only check for walls this is the expected "working as intended" behavior! If you want enemies to avoid each other your code should take that into account.
There are many solutions to this topic but how well it works highly depends on you and your game.

I suggest you learn about enemy steering behavior and the mp_potential_step function - in combination with mp_grid_path.
 
  • Like
Reactions: KPJ
Top