Scripting

Search The Documentation:

  1. Home
  2. Docs
  3. Scripting
  4. Examples
  5. Introduction To Paths

Introduction To Paths

Platform Compatibility

PC Mac OSX Oculus Quest
X X X

Artspark has a very simple waypoint based path system built-in, but to use it you do need to learn about waypoints, and path followers.

This is an example of making an object into a waypoint using makeWaypoint:

1
2
3
4
5
--Simple waypoint starting point (0) on first path (0)
local Path = 0
local Point = 0
local Wait = 0
obj.makeWaypoint(Path, Point, Wait)

Each additional waypoint you would want to increase the Point number, and can have an optional Wait value before it starts moving to the next point.

To make an object change to another path at the end of its path, we use a more advanced version of the same command:

1
2
3
4
5
6
--Simple end waypoint that goes to path 1 next
local Path = 0
local Point = 1
local Wait = 0
local GoToPath = 1
obj.makeWaypoint(Path, Point, Wait, -1, true, tostring(GoToPath))

Then the object that follows this path is set with followPath:

1
2
3
4
5
6
--Simple path follower
local Path = 0
local Point = 0
local Forward = true
obj.followPath(Path, Point, Forward)
obj.followerMoveSpd(0.1)

The built-in code handles moving between these points for the follower, to learn more about the path system visit Path System!

Tags
Was this article helpful to you? Yes No

How can we help?