-
Notifications
You must be signed in to change notification settings - Fork 5
Vectors
Berke edited this page Jun 23, 2026
·
1 revision
The engine exposes Vector2, Vector3, and Vector4 types to Lua using sol2. These types are fully constructible in scripts and provide direct access to their components and common math properties.
local v = Vector2()
local v = Vector2(x, y)| Name | Type |
|---|---|
| x | number |
| y | number |
You can read and write these directly:
v.x = 10
v.y = 20local len = v.lengthReturns the magnitude of the vector.
local len2 = v.lengthSquaredReturns squared length (faster than length).
local n = v.normalizedReturns a normalized copy of the vector.
local v = Vector2(3, 4)
print(v.length) -- 5
print(v.normalized.x) -- 0.6local v = Vector3()
local v = Vector3(x, y, z)| Name | Type |
|---|---|
| x | number |
| y | number |
| z | number |
local len = v.lengthReturns magnitude of the vector.
local len2 = v.lengthSquaredReturns squared magnitude.
local n = v.normalizedReturns a normalized copy.
local forward = Vector3(0, 0, 1)
local dir = forward.normalizedlocal v = Vector4()
local v = Vector4(x, y, z, w)| Name | Type |
|---|---|
| x | number |
| y | number |
| z | number |
| w | number |
-
Vector4currently exposes only raw component access. - No math properties (length/normalize) are bound yet.
local color = Vector4(1, 0, 0, 1) -- RGBA
print(color.w)