huenix
Member
I have a real-time turn-based game. When an AI "can_take_action" if they decide to move towards their target (instance_nearest()), need them to move in one direction 32px increment,
(that is the size of each step). The AI "can take action" is turned to false, til a timer event. Everything EXEPT using the pathfinding works. With that I get one of two things:
1) If (goalx/goaly) are set to the target, it over rides all other code, including "can_take_action" & "turn alarms events" and goes to the targets x/y in one go
or
2) if i set it to the +/-(32) (see code below) ... it works great until it comes to a wall... then it can't find away around unless i hard code it to with a "keep_more(up/down/left/right)" but still causes issues
does anyone know how to use pathfinding/grid do make this work, or how to edit my code to get it work properly???
var grid = mp_grid_create(0, 0, room_width/32, room_height/32, 32, 32)
var path = path_add();
mp_grid_add_instances(path, obj_solid, 1);
mp_grid_path(grid, path, x, y, x + move_x, y + move_y, false);
path_start(path, 1, path_action_stop, false)
(that is the size of each step). The AI "can take action" is turned to false, til a timer event. Everything EXEPT using the pathfinding works. With that I get one of two things:
1) If (goalx/goaly) are set to the target, it over rides all other code, including "can_take_action" & "turn alarms events" and goes to the targets x/y in one go
or
2) if i set it to the +/-(32) (see code below) ... it works great until it comes to a wall... then it can't find away around unless i hard code it to with a "keep_more(up/down/left/right)" but still causes issues
does anyone know how to use pathfinding/grid do make this work, or how to edit my code to get it work properly???
var grid = mp_grid_create(0, 0, room_width/32, room_height/32, 32, 32)
var path = path_add();
mp_grid_add_instances(path, obj_solid, 1);
mp_grid_path(grid, path, x, y, x + move_x, y + move_y, false);
path_start(path, 1, path_action_stop, false)