G
GamemakerTrialUser1
Guest
I've spent 5 / 15 days gone so far on the trial trying to solve this issue i'm having with Motion Planning with paths.
Lets dive into it shall we?
//Enemy Step Event - taken out of context as this is the only part of the code that I can't get to work the way I want:
//E_Scatter() Script - just copied and pasted from my chase script. instead of xgoal and y goal being the player, i've changed the co-ordinates to correspond with the start of the set path (p_G1):
I know it isn't right but my lack of experience with the software doesn't help me figure out how to achieve my goal.
what happens?
I want the enemy object, whilst it is normally chasing the player - after declaring its state from chase to scatter, will instead move wherever it is in the mp_grid to the start point of the set path [x1050,y630,p_G1]
Once the instance reaches those exact co-ordinates, i want to end the current direction / path and make the instance follow the set path [p_G1] until i change it's state back to chase.
I feel so close to resolving this but just spent too much time reading and researching i've confused myself over so many subtle changes. I'm hoping the problem is obvious.
Any advice and help would be greatly appreciated. If i can fix this issue, it''l help me fix other issues as i require a similar setup in future objects... [/gamemakerstory]
Lets dive into it shall we?
//Enemy Step Event - taken out of context as this is the only part of the code that I can't get to work the way I want:
Code:
dir = E_Scatter();
if (x = 1050 && y = 630) {
dir = path_start(p_G1,move_speed,path_action_restart,false);
}
//E_Scatter() Script - just copied and pasted from my chase script. instead of xgoal and y goal being the player, i've changed the co-ordinates to correspond with the start of the set path (p_G1):
Code:
/// E_Scatter();
global.G_Path = path_add();
if (mp_grid_path(egrid,global.G_Path,x,y,1050,630,false)) { // 1050 and 630 are starting point for path p_G1.
path_start(global.Ghost_Path, move_speed, path_action_stop, false); // move_speed = 1;
var xx = path_get_point_x(global.G_Path, 0); // this section I copied from a youtube vid. lost the vid.
var yy = path_get_point_y(global.G_Path, 0); // and don't fully understand it, but it works for chase.player.
if (x < xx) { dir = 0; } //right
else if (x > xx) { dir = 2; } //left
else if (y > yy) { dir = 1; } //up
else if (y < yy) { dir = 3; } //down
path_end();
path_delete(global.G_Path);
return dir;
}
what happens?
To recap:the enemy indeed moves to the specified co-ordinates. But upon arrival, it wanders up and down a couple of tiles in an endless loop
I want the enemy object, whilst it is normally chasing the player - after declaring its state from chase to scatter, will instead move wherever it is in the mp_grid to the start point of the set path [x1050,y630,p_G1]
Once the instance reaches those exact co-ordinates, i want to end the current direction / path and make the instance follow the set path [p_G1] until i change it's state back to chase.
I feel so close to resolving this but just spent too much time reading and researching i've confused myself over so many subtle changes. I'm hoping the problem is obvious.
Any advice and help would be greatly appreciated. If i can fix this issue, it''l help me fix other issues as i require a similar setup in future objects... [/gamemakerstory]