Dev » Lua API » vector3
← Back to all classes

vector3

Math 3 Properties 4 Methods

vector3

The vector3 class is the primary 3D coordinate type used across Stranded III for positions, rotations (Euler angles in degrees), velocities, and scales. Supports arithmetic metamethods (+, -, *).

Overview

Properties (3)

Property Type Summary
x number The X coordinate of the 3D vector.
y number The Y coordinate of the 3D vector (height in Godot coordinates).
z number The Z coordinate of the 3D vector.

Methods (4)

Method Signature Returns Summary
vector3:dot(other) number Calculates the dot product with another 3D vector.
vector3:length() number Calculates the length of the vector.
vector3.new(x, y, z) vector3 Constructs a new 3D vector.
vector3:normalized() vector3 Returns a normalized unit vector.

Detailed Reference

# x PROPERTY
vector3.x
The X coordinate of the 3D vector.
Parameters
None
Returns
number

The X coordinate component.

Description

Reads or writes the X component of the 3D vector.

# y PROPERTY
vector3.y
The Y coordinate of the 3D vector (height in Godot coordinates).
Parameters
None
Returns
number

The Y coordinate component.

Description

Reads or writes the Y component (height) of the 3D vector.

# z PROPERTY
vector3.z
The Z coordinate of the 3D vector.
Parameters
None
Returns
number

The Z coordinate component.

Description

Reads or writes the Z component of the 3D vector.

# dot METHOD
vector3:dot(other)
Calculates the dot product with another 3D vector.
Parameters
ParameterTypeDefaultDescription
othervector3

The other 3D vector.

Returns
number

The scalar dot product.

Description

Calculates x1 x2 + y1 y2 + z1 * z2.

# length METHOD
vector3:length()
Calculates the length of the vector.
Parameters
None
Returns
number

Euclidean magnitude of the vector.

Description

Calculates the Euclidean distance from the origin sqrt(x^2 + y^2 + z^2).

# new METHOD
vector3.new(x, y, z)
Constructs a new 3D vector.
Parameters
ParameterTypeDefaultDescription
xnumber

The X coordinate.

ynumber

The Y coordinate.

znumber

The Z coordinate.

Returns
vector3

Newly constructed 3D vector.

Description

Creates a new 3D vector with the specified coordinates.

local pos = vector3.new(100, 10, -50)
# normalized METHOD
vector3:normalized()
Returns a normalized unit vector.
Parameters
None
Returns
vector3

Unit vector with length 1.0.

Description

Returns a scaled vector pointing in the same direction with length 1.0.