Vector3

Inherits from Object. Is a struct, meaning that assignments will create copies and comparisons will return true if all fields are equivalent.

Initialization

Vector3 takes up to three floats X, Y, and Z as parameters when initializing.

# create an empty 0,0,0 vector
vector = Vector3();

# create a vector with x=5.5, y=6.0, z=24.8
vector = Vector3(5.5, 6.0, 24.8);

# create a vector with x,y,z = 1.2
vector = Vector3(1.2);

# create a vector with x=5.5, y=6.0, z=0
vector = Vector3(5.5, 6.0);

Fields

Field
Type
Readonly
Description

X

float

false

X axis of the vector.

Y

float

false

Y axis of the vector.

Z

float

false

Z axis of the vector.

Normalized

Vector3

true

Normalized version of the vector.

Magnitude

float

true

Returns the magnitude of the vector.

Functions

Function
Returns
Description

Scale(scale: float)

Vector3

Returns the Vector3 multiplied by scale.

Static Fields

Can be accessed by referencing Vector3 directly (example: Vector3.Up)

Field
Type
Description

Up

Vector3

Down

Vector3

Left

Vector3

Right

Vector3

Forward

Vector3

Back

Vector3

Zero

Vector3

One

Vector3

Static functions

Function
Returns
Description

Lerp(a: Vector3, b: Vector3, t: float)

Vector3

Returns a Vector3 lerped between a and b using scale t. T must be between 0 and 1.

LerpUnclamped(a: Vector3, b: Vector3, t: float)

Vector3

Returns a Vector3 lerped between a and b using scale t. T can be outside 0 and 1.

Slerp(a: Vector3, b: Vector3, t: float)

Vector3

Returns a Vector3 spherical lerped between a and b using scale t. T must be between 0 and 1.

SlerpUnclamped(a: Vector3, b: Vector3, t: float)

Vector3

Returns a Vector3 spherical lerped between a and b using scale t. T can be outside 0 and 1.

GetRotationDirection(a: Vector3, b: Vector3)

Vector3

Gets the relational Vector3 b using a as a reference. This is equivalent to setting MapObject.Forward to Vector a, and finding the relative b vector.

Distance(a: Vector3, b: Vector3)

float

Returns the distance between two Vector3s.

Project(a: Vector3, b: Vector3)

Vector3

Returns a projected on b.

Multiply(a: Vector3, b: Vector3)

Vector3

Returns the Vector3 of each element in a multiplied by each element of b. It returns the Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z).

Divide(a: Vector3, b: Vector3)

Vector3

Returns the Vector3 of each element in a divided by each element of b.

Angle(a: Vector3, b: Vector3)

float

Returns the angle between a and b. Always a positive value.

SignedAngle(a: Vector3, b: Vector3, axis: Vector3)

float

Returns the signed angle between a and b using the given axis.

Cross(a: Vector3, b: Vector3)

Vector

Returns the cross product of a and b.

Dot(a: Vector3, b: Vector3)

float

Returns the dot product of a and b.

RotateTowards(a: Vector3, b: Vector3, maxAngle: float, maxMagnitude: float)

Vector3

Returns the Vector3 that is rotated from a to b using maxAngle degrees and changing magnitude by at most maxMagnitude.

Last updated