GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Dog_Theft Aug 28, 2019 @ 5:09am
Need help stopping an enemy at a path in Game Maker Studio
So i've been following this tutorial on NPC paths :

https://www.youtube.com/watch?v=LYAskDJ75Ss&list=PL_4rJ_acBNMEGUMuO7IbivLgnvUxHklnj&index=15

and successfully made the base obj as in the video.

Here's the code(path related only):

obj_NPCBase:

<CREATE EVENT>
//Path
Target = instance_create(x,y,obj_target);
Path = -1;

<STEP EVENT>
if(Path != -1){
dir = point_direction(Target.x,Target.y,x,y);
dist = point_distance(Target.x,Target.y,x,y);

dx = lengthdir_x(1,dir);
dy = lengthdir_y(1,dir);

x -= dx;
y -= dy;
if(dist > 128){
x = Target.x;
y = Target.y;
}
}
<USER DEFINED 0>
///Assign path
with(Target){
path_start(other.Path,1,0,1);
}

obj_enemy:

<CREATE EVENT>
event_inherited();

Path = patrol;

event_user(0);

Now i want make the enemy stop at the middle of the path.I made an obj_pause and make it collide with the enemy,every time they collide the enemy will stop.

The problem is that only the enemy will stop,the obj_followtarget just keep going.And when the enemy is moving back again,it will go out of the path to keep up with the moving obj_target.I've tried many ways to move the target but none works.

My main goal is to stop the enemy,and resume the path when it need to.Any suggestion on how to work this out?
Date Posted: Aug 28, 2019 @ 5:09am
Posts: 0