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
Properties
Section titled “Properties”| 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.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
PathFollowNode:connect(event, handler)
Section titled “PathFollowNode:connect(event, handler)”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)eventPathFollowNodeEvent|stringhandlerfun(value:any, source: PathFollowNode)
Returns integer id Connection id for disconnect
PathFollowNode:get_property(path)
Section titled “PathFollowNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("progress")pathPathFollowNodeProperty|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.
self.node:set_property("progress", 1.5)pathPathFollowNodeProperty|stringvalueanyy?number
PathFollowNode:follow_ratio()
Section titled “PathFollowNode:follow_ratio()”How far along its path the follower is: 0 at the start, 1 at the end.
if platform:follow_ratio() > 0.5 then ... endReturns number
PathFollowNode:follow_set_ratio(ratio)
Section titled “PathFollowNode:follow_set_ratio(ratio)”Puts the follower at a fraction of its path (0..1) at once.
platform:follow_set_ratio(0.25)rationumber
PathFollowNode:follow_restart()
Section titled “PathFollowNode:follow_restart()”Back to the start, moving forwards again (after “path_finished”).
self.node:get_node("Route/Cart"):follow_restart()In a scene file
Section titled “In a scene file”{ "type": "PathFollowNode", "name": "PathFollow", "position": [ 0, 0 ], "properties": { "progress": 0, "speed": 0, "loop": "Stop" }}