vector(x: number, y: number, z: number): vector
X coordinate of 3D position
Y coordinate of 3D position
Z coordinate of 3D position
Creates a new vector object. Please note that you need to load the built-in vector library with require "vector"
vector_object:angles(): number, number, number
Converts the vector to an angle and returns the pitch, yaw and roll
vector_object:dist2d(other: vector): number
Returns the cross product / vector product of itself and another vector
vector_object:dist(other: vector): number
Vector to calculate the distance to
Returns the 3d distance to another vector
vector_object:dist(other: vector): number
Vector to calculate the distance to
Returns the 2d distance to another vector
vector_object:dot(): number
Returns the dot product of the vector
vector_object:init(x: number, y: number, z: number): vector
X coordinate of 3D position
Y coordinate of 3D position
Z coordinate of 3D position
Overwrites the X, Y and Z coordinates of the vector object, returning itself
:init_from_angles
vector_object:init_from_angles(pitch: number, yaw: number[, roll: number]): vector
Converts the pitch, yaw and roll passed to a forward vector and overwrites the X, Y and Z coordinates with that. Returns itself
vector_object:length(): number
Returns the length (magnitude)
vector_object:length2d(): number
Returns the 2d length (X and Y components)
vector_object:length2dsqr(): number
Returns the squared 2d length (X and Y components, faster than :length2d)
vector_object:lengthsqr(): number
Returns the squared length (faster than :length)
vector_object:lerp(to: vector, percentage: number): vector
Interpolation percentage (0-1)
Interpolates by the specified percentage between the 2 vectors.
vector_object:normalize()
Normalizes the vector, dividing it by it's own length (resulting in a unit vector with length = 1)
vector_object:normalized(): vector
Returns a new unit vector, divided it by it's own length
vector_object:scale(scalar: number)
Scales the vector by the specified value.
vector_object:scaled(scalar: number): vector
Returns a new vector, scaled by the specified value.
vector_object:to(other: vector): vector
Returns the forward vector from itself to another vector
vector_object:unpack(): number, number, number
Returns the X, Y and Z coordinate of the vector object. They can also be accessed by vec.x, vec.y, etc
vector_object:vectors(): vector, vector
Returns the right and up vector of a forward vector