L
Lks10
Guest
The red square moves towards the green rectangle using mp_grid_path, but it appears that the red square likes cutting corners and walking through the wall. How can I fix this?
This is the creation code of the control object
This is the step event of the red square.
player is the name of the green rectangle object.
Is there a way to prevent the red square from cutting corners?
This is the creation code of the control object
Code:
grid = mp_grid_create(0,0,room_width/32,room_height/32,32,32);
mp_grid_add_instances(grid,wall,false);
player is the name of the green rectangle object.
Code:
if target = -1{
if instance_exists(player){
target = player.id;
}
}
if target = -1{ exit }
tx = (target.x div 32)*32+16
ty = (target.y div 32)*32+16
if mp_grid_path(control.grid,path,x,y,tx,ty,1){
path_start(path,spd,path_action_stop,true)
}