J
jaber
Guest
Hi all,
for my HTML top down shooter I am trying to let a second AI character (lets call it follower) to follow the main charachter and for that I have created a grid
and I have added the code to the step event of the follower
for debugging purposes, I also printed out my Grid and the outcome of mp_grid_get_cell; I also printed a circle in the exact position where the function is checking
draw event of folower
draw gui
as you see from my test video I have recorded, the mp_grid_get_cell is throwing -1 no matter where the charachter steps!
am I skipping something here? I would appreciate any advice or help
thnx
J
for my HTML top down shooter I am trying to let a second AI character (lets call it follower) to follow the main charachter and for that I have created a grid
Code:
/// grid creation code
global.grid = mp_grid_create(0,0,room_width/32, room_height/32, 32,32 );
mp_grid_add_instances(global.grid,obj_box_collider,0);
Code:
//step event
targetX = (obj_Player.x div 32)*32 + 32;
targetY = (obj_Player.y div 32)*32 + 32;
//find path
if path_exists(path) path_delete(path);
path = path_add();
if (mp_grid_get_cell(global.grid, targetX, targetY) == 0)
{
if mp_grid_path(global.grid, path, x, y, targetX, targetX, 1){
path_start(path,4,path_action_stop,0);
}
}
else path_delete(path);
draw event of folower
Code:
draw_circle_colour(targetX, targetY, 100, c_white, c_black, false);
draw_self();
draw_set_alpha(0.3);
mp_grid_draw(global.grid);
draw_set_alpha(1);
Code:
draw_text(902, 440, "get cell " + string(mp_grid_get_cell(global.grid, targetX, targetY)));
as you see from my test video I have recorded, the mp_grid_get_cell is throwing -1 no matter where the charachter steps!
am I skipping something here? I would appreciate any advice or help
thnx
J