T
TankRockett
Guest
So i've been following this tutorial on NPC paths :
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 suggestions ?
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 suggestions ?