Path
A curve through points with Bézier handles, edited in the viewport: routes, rails, moving platforms’ tracks, camera paths. Add a Path Follow under it.
Type: PathNode · Category: Animation & Effects · Also found as: path, curve, bezier, route, rail
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
closed |
boolean | false |
Join the last point back to the first (a loop). |
bakeInterval |
number | 6 |
Distance between the points the curve is turned into (px): smaller follows the curve more closely. Range 1 to 64. |
lineWidth |
number | 0 |
Draw the path in the game this wide (rails, ropes); 0 = invisible (the editor always shows it). Range 0 to 64. |
color |
color | #7dd3fcff |
Colour of the drawn path (and of its outline in the editor). |
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.
PathNode:get_property(path)
Section titled “PathNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("closed")pathPathNodeProperty|string
Returns any
PathNode:set_property(path, value, y)
Section titled “PathNode: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("closed", true)pathPathNodeProperty|stringvalueanyy?number
PathNode:path_length()
Section titled “PathNode:path_length()”The path’s length in pixels (along the curve).
local len = self.node:get_node("Route"):path_length()Returns number
PathNode:path_point_at(distance)
Section titled “PathNode:path_point_at(distance)”The point at a distance along the path (world) and the direction the path goes there.
local pos, dir = route:path_point_at(route:path_length() * 0.5)distancenumberPixels from the start (clamped)
Returns Vec2 position World position, Vec2 direction Unit vector (world)
PathNode:path_closest_offset(x, y)
Section titled “PathNode:path_closest_offset(x, y)”The distance along the path of the point nearest to a world position (snap something onto the path).
local d = route:path_closest_offset(player.position)xnumber|Vec2y?number
Returns number distance
PathNode:path_point_count()
Section titled “PathNode:path_point_count()”How many points the path has.
for i = 1, route:path_point_count() do print(route:path_get_point(i)) endReturns integer
PathNode:path_get_point(index)
Section titled “PathNode:path_get_point(index)”A point (1-based): its position and its in / out handles, local to the path.
local pos, handle_in, handle_out = route:path_get_point(1)indexinteger
Returns Vec2 position, Vec2 handle_in Offset from the point, Vec2 handle_out Offset from the point
PathNode:path_set_point(index, position, handle_in, handle_out)
Section titled “PathNode:path_set_point(index, position, handle_in, handle_out)”Moves a point (1-based), optionally setting its handles (offsets; zero = a sharp corner).
route:path_set_point(2, Vec2(200, 40), Vec2(-30, 0), Vec2(30, 0))indexintegerpositionVec2handle_in?Vec2handle_out?Vec2
PathNode:path_add_point(position, handle_in, handle_out)
Section titled “PathNode:path_add_point(position, handle_in, handle_out)”Adds a point at the end (local to the path), optionally with handles.
route:path_add_point(Vec2(400, 0))positionVec2handle_in?Vec2handle_out?Vec2
PathNode:path_remove_point(index)
Section titled “PathNode:path_remove_point(index)”Removes a point (1-based).
route:path_remove_point(route:path_point_count())indexinteger
PathNode:path_clear()
Section titled “PathNode:path_clear()”Removes every point.
route:path_clear()In a scene file
Section titled “In a scene file”{ "type": "PathNode", "name": "Path", "position": [ 0, 0 ], "properties": { "closed": false, "bakeInterval": 6, "lineWidth": 0 }}