A set of Vector2 points forming a 2D path
Name | Return Type | Description |
---|---|---|
count | number Read-only | Returns the number of points in this path |
this[index] | Transform Read-only | Returns the point at the specified index |
last | Transform Read-only | Returns the last point in this path |
Creates a new empty 2d Path
Returns: Path2d
myPath = Path2d:New()
Creates a 2d path from a list of Vector2 points
Returns: Path2d
Parameters:
Name | Type | Default | Description |
---|---|---|---|
positionList | Vector2[] | The list of points |
myPath = Path2d:New({point1, point2, point3})
Creates a path from a list of Vector3 points
Returns: Path2d
Parameters:
Name | Type | Default | Description |
---|---|---|---|
positionList | Vector3[] | The list of points |
myPath = Path:New({point1, point2, point3})
Generates a regular polygon path
Returns: Path2d (The new path)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
sides | number | The number of sides for the polygon |
myPath = Path2d:Polygon(6)
Inserts a new point at the end of the path
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
point | Vector2 | The point to be inserted at the end of the path |
myPath:Insert(Transform:New(pos, rot)
Inserts a new point at the specified index
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
point | Vector2 | The point to be inserted | |
index | number | The index at which to insert the point |
myPath:Insert(transform, index)
Converts the 2D path to a 3D path on the YZ plane (i.e. with all x values set to 0)
Returns: Path (A 3D Path based on the input but with all x as 0: (0, inX, inY))
my3dPath = my2dPath:OnX()
Converts the 2D path to a 3D path on the XZ plane (i.e. with all y values set to 0)
Returns: Path (A 3D Path based on the input but with all y as 0: (inX, 0, inY))
my3dPath = my2dPath:OnY()
Converts the 2D path to a 3D path on the XY plane (i.e. with all z values set to 0)
Returns: Path (A 3D Path based on the input but with all z as 0: (inX, inY, 0))
my3dPath = my2dPath:OnZ()
Transforms all points in the path by the specific amount
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
transform | Transform | The transform to be applied to all points in the path |
myPath:TransformBy(transform)
Changes the position of all points in the path by a given amount
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
amount | Vector2 | The distance to move the points |
myPath:TranslateBy(Vector3:up)
Rotates all points in the path around the origin by a given amount
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
amount | Rotation | The amount by which to rotate the path |
myPath:RotateBy(Rotation.New(45, 0, 0)
Scales the path
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
scale | number | The scaling factor to apply to the path |
myPath:ScaleBy(2)
Scales the path
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x | number | The x scaling factor to apply to the path | |
y | number | The y scaling factor to apply to the path |
myPath:ScaleBy(2, 1)
Scales the path
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
scale | Vector2 | The scaling factor to apply to the path |
myPath:ScaleBy(myVector2
Moves all points on the path so that their common center is the origin
Returns: nil
myPath:Center()
Reorders the points so that point at the given index is shifted to be the first point
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
index | number | The index of the point to make the new first point |
myPath:StartingFrom(3)
Returns the index of the point closest to the given position
Returns: number
Parameters:
Name | Type | Default | Description |
---|---|---|---|
point | Vector2 | The 3D position that we are seeking the closest to |
myPath:FindClosest(Vector3:New(10, 2, 4)
Returns the index of the point with the smallest X value
Returns: number
myPath:FindMinimumX()
Returns the index of the point with the smallest Y value
Returns: number
myPath:FindMinimumY()
Returns the index of the point with the biggest X value
Returns: number
myPath:FindMaximumX()
Returns the index of the point with the biggest Y value
Returns: number
myPath:FindMaximumY()
Scales and shifts all points so that they fit in a 1 unit square at the origin
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
size | number | 1 | The size of the square to fit the path into |
myPath:Normalize(size)
Resamples the path at a specified spacing
Returns: nil (The resampled path)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
spacing | number | The space between points in the new pat |
myPath:Resample(spacing)