Skip to content

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

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.

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

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("closed")
  • path PathNodeProperty|string

Returns any

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("closed", true)
  • path PathNodeProperty|string
  • value any
  • y? number

The path’s length in pixels (along the curve).

local len = self.node:get_node("Route"):path_length()

Returns number

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)
  • distance number Pixels from the start (clamped)

Returns Vec2 position World position, Vec2 direction Unit vector (world)

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)
  • x number|Vec2
  • y? number

Returns number distance

How many points the path has.

for i = 1, route:path_point_count() do print(route:path_get_point(i)) end

Returns integer

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)
  • index integer

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))
  • index integer
  • position Vec2
  • handle_in? Vec2
  • handle_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))
  • position Vec2
  • handle_in? Vec2
  • handle_out? Vec2

Removes a point (1-based).

route:path_remove_point(route:path_point_count())
  • index integer

Removes every point.

route:path_clear()
{
"type": "PathNode",
"name": "Path",
"position": [
0,
0
],
"properties": {
"closed": false,
"bakeInterval": 6,
"lineWidth": 0
}
}