M
memerson.d
Guest
Hello, I am trying to make my AI character walk into a building, and then, upon arrival, leave and head for point (0,0) in the room. I will paste the code below. He walks into the building and makes it to his destination, but then after the if statement is true in the step event, he just freezes even though I have made a new path and started it. Why is this happening? How can I continuously, or dynamically find a path for this character when he needs a new one?
Thanks!
Create Event:
speed = 3;
myPath = path_add();
path_set_kind(myPath, 1);
path_set_precision(myPath, 3);
target = instance_find(inBarNodeObj,0);
//mp_potential_path_object(myPath, target.x, target.y, speed, 2, wallObj);
mp_grid_path(global.aiGrid, myPath, x, y, target.x, target.y, 1);
path_start(myPath, speed, path_action_stop, 0);
Step Event:
if(x == target.x and y == target.y){
//path_end();
path_delete(myPath);
myPath = path_add();
mp_grid_path(global.aiGrid, myPath, x, y, 0, 0, 1);
alarm[1] = 10; //Alarm calls path_start(myPath, speed, path_action_stop, 0)
}
Thanks!
Create Event:
speed = 3;
myPath = path_add();
path_set_kind(myPath, 1);
path_set_precision(myPath, 3);
target = instance_find(inBarNodeObj,0);
//mp_potential_path_object(myPath, target.x, target.y, speed, 2, wallObj);
mp_grid_path(global.aiGrid, myPath, x, y, target.x, target.y, 1);
path_start(myPath, speed, path_action_stop, 0);
Step Event:
if(x == target.x and y == target.y){
//path_end();
path_delete(myPath);
myPath = path_add();
mp_grid_path(global.aiGrid, myPath, x, y, 0, 0, 1);
alarm[1] = 10; //Alarm calls path_start(myPath, speed, path_action_stop, 0)
}