Skip to content

Instantly share code, notes, and snippets.

@MysteryPoo
Created February 11, 2015 05:33
Show Gist options
  • Save MysteryPoo/2229cf84f17c6115555d to your computer and use it in GitHub Desktop.
Save MysteryPoo/2229cf84f17c6115555d to your computer and use it in GitHub Desktop.
Start a guard at a specific node on a path.
var node = 2; // Node number 2... for a random node you can do: var node = irandom( path_get_number( path );
// Set position to the position of the node
x = path_get_point_x( path, node );
y = path_get_point_y( path, node );
// path_position is a normalized value based on the length of the path.
// path_position = 1 is the end of any path and path_position = 0.5 would be halfway of any path.
// After setting the physical position of an object to match that of the path's nodal position,
// you then have to set the normalized position of the path if you intend for the object to
// continue following along that path. If I'm unclear I'll try to explain later.
path_position = ( 1 / path_get_number( path ) ) * node;
path_speed = -path_speed; // Reverse the direction of the path if you want.
// Hope that helps. You should easily be able to use this kind of code to reduce your objects back down to a single obj_Guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment