Skip to content

Path Follow

Travels along its parent Path: speed, loop / ping-pong / stop, faces the way it goes. Put a sprite, a platform or an enemy under it.

Type: PathFollowNode · Category: Animation & Effects · Also found as: path follow, follower, moving platform

Property Type Default Description
progress number 0 Distance travelled along the parent path (px). Set it to place the follower; scripts can animate it. Range 0 to 10000.
speed number 0 Pixels per second it moves along the path by itself (negative: backwards; 0: only scripts move it). Range -2000 to 2000.
loop enum: Stop, Loop, PingPong Stop At the end: Stop (path_finished), Loop (start again) or Ping Pong (turn back).
rotate boolean true Turn to face the direction it travels.
sideOffset number 0 Pixels to the side of the path (positive: to the right of the travel direction) - lanes, offsets. Range -500 to 500.

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Connects a handler to one of this node’s events: path_finished (The follower reached the end of its path (loop: Stop)), path_looped (The follower wrapped round or turned back (Loop / Ping Pong)); the tree events; custom ones.

self.node:connect("path_finished", function(value, source) Log.info("path_finished") end)
  • event PathFollowNodeEvent|string
  • handler fun(value: any, source: PathFollowNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("progress")
  • path PathFollowNodeProperty|string

Returns any

PathFollowNode:set_property(path, value, y)

Section titled “PathFollowNode:set_property(path, value, y)”

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("progress", 1.5)
  • path PathFollowNodeProperty|string
  • value any
  • y? number

How far along its path the follower is: 0 at the start, 1 at the end.

if platform:follow_ratio() > 0.5 then ... end

Returns number

Puts the follower at a fraction of its path (0..1) at once.

platform:follow_set_ratio(0.25)
  • ratio number

Back to the start, moving forwards again (after “path_finished”).

self.node:get_node("Route/Cart"):follow_restart()
{
"type": "PathFollowNode",
"name": "PathFollow",
"position": [
0,
0
],
"properties": {
"progress": 0,
"speed": 0,
"loop": "Stop"
}
}