O
OttoMagao
Guest
So I want obj_enemy to follow obj_player (If it can see it with no walls inbetween) avoiding obj_walls. This is what I have as a code:
On the obj_control create event:
global.grid=mp_grid_create(0,0,room_width/32,room_height/32,32,32);
On the obj_enemy create event:
global.path=path_add();
On the obj_enemy step event:
with (obj_smoke) {
if ( !collision_line(x, y, obj_player.x, obj_player.y, obj_walls, 1, 0) and distance_to_object(obj_player < 2048) ) {
//Chasing
global.chasing = true;
global.path=path_add()
mp_grid_path(global.grid,global.path,x,y,obj_player.x,obj_player.y,false)
mp_grid_add_instances(global.path,obj_walls,true)
path_start(global.path,10,0,1)
show_debug_message("Player found");
}
}
With that the obj_enemy is not moving at all. With the show_debug_message I found that it is detecting the player, but it isn't following it. Thanks
On the obj_control create event:
global.grid=mp_grid_create(0,0,room_width/32,room_height/32,32,32);
On the obj_enemy create event:
global.path=path_add();
On the obj_enemy step event:
with (obj_smoke) {
if ( !collision_line(x, y, obj_player.x, obj_player.y, obj_walls, 1, 0) and distance_to_object(obj_player < 2048) ) {
//Chasing
global.chasing = true;
global.path=path_add()
mp_grid_path(global.grid,global.path,x,y,obj_player.x,obj_player.y,false)
mp_grid_add_instances(global.path,obj_walls,true)
path_start(global.path,10,0,1)
show_debug_message("Player found");
}
}
With that the obj_enemy is not moving at all. With the show_debug_message I found that it is detecting the player, but it isn't following it. Thanks
Last edited by a moderator: