A
Agletsio
Guest
Hi there,
My goal is to have my NPC follow a path until the player reaches within a certain distance of it, where then the NPC would start following the player. If the player manages to exit that certain distance again, I would want the NPC to return to it's path.
At present, I can only make these two options work separately and can't get them to function together.
This is my current code set-up (in a Step Event). With this code the NPC does nothing until the player enters within it's 128 radius, where it's start walking the path instead of chasing the player:
if distance_to_object(Player) <= 128
{
move_towards_point(Player.x, Player.y, 2)
}
else
{
if distance_to_object(Player) > 128
{
path_start (path1, 2, path_action_restart, true)
}
}
Any help or guidance will be much appreciated! Been trying to find answer for hours now without any luck!
My goal is to have my NPC follow a path until the player reaches within a certain distance of it, where then the NPC would start following the player. If the player manages to exit that certain distance again, I would want the NPC to return to it's path.
At present, I can only make these two options work separately and can't get them to function together.
This is my current code set-up (in a Step Event). With this code the NPC does nothing until the player enters within it's 128 radius, where it's start walking the path instead of chasing the player:
if distance_to_object(Player) <= 128
{
move_towards_point(Player.x, Player.y, 2)
}
else
{
if distance_to_object(Player) > 128
{
path_start (path1, 2, path_action_restart, true)
}
}
Any help or guidance will be much appreciated! Been trying to find answer for hours now without any luck!