L
Luke Murray
Guest
Hello,
I'm working on a simple tower defense styled project. In the room_create event, I establish a default grid for enemies to use, and add some basic objects to be avoided to it:
Enemies start on this path by default, towards the user's base unless there is a player-controlled unit that is closer:
The issue I'm running into is that when I build walls, which I want enemies to avoid, during gameplay (using the obj_building object type) the enemies ignore and just pass right through instead of going around. My assumption is that this happens because the new instance of obj_building has been added after the grid was created.
I would greatly appreciate any guidance on how to update the grid/enemy path, if thats not possible, a clean way to "reboot" the grid/enemy path each time I add a new building to the field.
Thanks,
I'm working on a simple tower defense styled project. In the room_create event, I establish a default grid for enemies to use, and add some basic objects to be avoided to it:
GML:
global.nme_grid_ground = mp_grid_create(0, 0, room_width div 32, room_height div 32, 32, 32);
mp_grid_add_instances(global.nme_grid_ground, obj_building, false);
mp_grid_add_instances(global.nme_grid_ground, obj_solid, false);
mp_grid_add_instances(global.nme_grid_ground, obj_slow, false);
mp_grid_add_instances(global.nme_grid_ground, obj_water, false);
Code:
if mp_grid_path(global.nme_grid_ground, nme_path[w], x, y, target.x, target.y-8, 0) {
path_start(nme_path[w],move,path_action_stop,0)
}
I would greatly appreciate any guidance on how to update the grid/enemy path, if thats not possible, a clean way to "reboot" the grid/enemy path each time I add a new building to the field.
Thanks,