• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Help With Paths?

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)

}
 
B

Becon

Guest
Does the new path have a new target set? Wouldn't he just stand there if you don't tell him to go??
 
M

memerson.d

Guest
Does the new path have a new target set? Wouldn't he just stand there if you don't tell him to go??
Yeah I fixed that issue. I tried putting the creation code into the step event instead, so it had a valid target, and it still just stands in place. I drew the grid and path to the screen and the path to the new target is drawn correctly, but when path_start(...) is called, he does not move.

For now I am using mp_potential_step_object and it seems to be working well enough. I just feel like this approach will use more CPU time once I have multiple objects pathfinding.
 
Top