Skip to main content
The Vector3 class represents a 3-dimensional vector with x, y, and z coordinates. It’s used for positions, directions, and transformations in 3D space.

Constructor

Vector3.new
function
Creates a new 3D vector

Properties

x
number
The x coordinate of the vector (read/write)
y
number
The y coordinate of the vector (read/write)
z
number
The z coordinate of the vector (read/write)

Examples

Creating a Vector3

import "raylib" for Vector3

// Create a 3D position
var position = Vector3.new(10.0, 5.0, 0.0)

// Create a direction vector
var direction = Vector3.new(0.0, 1.0, 0.0)

Modifying Vector3 Properties

import "raylib" for Vector3

var pos = Vector3.new(0, 0, 0)

// Update all coordinates
pos.x = 100
pos.y = 50
pos.z = 25

3D Movement

import "raylib" for Vector3

var position = Vector3.new(0, 0, 0)
var velocity = Vector3.new(1.0, 0.0, 0.5)

// Update position
position.x = position.x + velocity.x
position.y = position.y + velocity.y
position.z = position.z + velocity.z

Build docs developers (and LLMs) love