Skip to content

Vector3

A three-component vector used for positions, directions, and scales in 3D space. Vector3 is the workhorse type in VRChat worlds for everything from teleporting players to computing directions between objects.

Properties

PropertyTypeAccess
backVector3get
downVector3get
forwardVector3get
Itemfloatget, set
kEpsilonfloatget
kEpsilonNormalSqrtfloatget
leftVector3get
magnitudefloatget
negativeInfinityVector3get
normalizedVector3get
oneVector3get
positiveInfinityVector3get
rightVector3get
sqrMagnitudefloatget
upVector3get
xfloatget, set
yfloatget, set
zfloatget, set
zeroVector3get

back

Static. Shorthand for Vector3(0, 0, -1).

let bk: Vector3 = Vector3.back

down

Static. Shorthand for Vector3(0, -1, 0).

let downward: Vector3 = Vector3.down

forward

Static. Shorthand for Vector3(0, 0, 1).

let fwd: Vector3 = Vector3.forward

left

Static. Shorthand for Vector3(-1, 0, 0).

let l: Vector3 = Vector3.left

magnitude

The length of this vector.

let speed: float = velocity.magnitude

normalized

Returns this vector with a magnitude of 1, preserving direction.

let dir: Vector3 = offset.normalized

one

Static. Shorthand for Vector3(1, 1, 1).

transform.localScale = Vector3.one

Static. Shorthand for Vector3(1, 0, 0).

let r: Vector3 = Vector3.right

up

Static. Shorthand for Vector3(0, 1, 0).

let upward: Vector3 = Vector3.up

x

The X (horizontal / red axis) component.

let horizontal: float = pos.x

y

The Y (vertical / green axis) component.

let height: float = pos.y

z

The Z (depth / blue axis) component.

let depth: float = pos.z

zero

Static. Shorthand for Vector3(0, 0, 0).

transform.localPosition = Vector3.zero

Methods

Angle

static Angle(from: Vector3, to: Vector3) -> float

Static. Returns the angle in degrees between two vectors.

let angle: float = Vector3.Angle(a, b)

ClampMagnitude

static ClampMagnitude(vector: Vector3, maxLength: float) -> Vector3

Cross

static Cross(lhs: Vector3, rhs: Vector3) -> Vector3

Static. Returns the cross product of two vectors (perpendicular vector).

let normal: Vector3 = Vector3.Cross(a, b)

Distance

static Distance(a: Vector3, b: Vector3) -> float

Static. Returns the distance between two points.

let dist: float = Vector3.Distance(a, b)

Dot

static Dot(lhs: Vector3, rhs: Vector3) -> float

Static. Returns the dot product of two vectors. Positive when facing similar directions.

let alignment: float = Vector3.Dot(forward, toTarget)

Equals

Equals(other: object) -> bool
Equals(other: Vector3) -> bool

GetHashCode

GetHashCode() -> int

GetType

GetType() -> SystemType

Lerp

static Lerp(a: Vector3, b: Vector3, t: float) -> Vector3

Static. Linearly interpolates between two vectors by t (clamped 0-1).

let mid: Vector3 = Vector3.Lerp(start, end, 0.5)

LerpUnclamped

static LerpUnclamped(a: Vector3, b: Vector3, t: float) -> Vector3

Magnitude

static Magnitude(vector: Vector3) -> float

Max

static Max(lhs: Vector3, rhs: Vector3) -> Vector3

Min

static Min(lhs: Vector3, rhs: Vector3) -> Vector3

MoveTowards

static MoveTowards(current: Vector3, target: Vector3, maxDistanceDelta: float) -> Vector3

Static. Moves a point toward a target, capped at a maximum distance per call.

let next: Vector3 = Vector3.MoveTowards(current, target, speed * Time.deltaTime)

new

static new(x: float, y: float, z: float) -> Vector3
static new(x: float, y: float) -> Vector3

Normalize

Normalize() -> void
static Normalize(value: Vector3) -> Vector3

Static. Returns the given vector with magnitude 1.

let unit: Vector3 = Vector3.Normalize(direction)

OrthoNormalize

static OrthoNormalize(normal: Vector3, tangent: Vector3, binormal: Vector3) -> Vector3
static OrthoNormalize(normal: Vector3, tangent: Vector3) -> Vector3

Project

static Project(vector: Vector3, onNormal: Vector3) -> Vector3

ProjectOnPlane

static ProjectOnPlane(vector: Vector3, planeNormal: Vector3) -> Vector3

Reflect

static Reflect(inDirection: Vector3, inNormal: Vector3) -> Vector3

RotateTowards

static RotateTowards(current: Vector3, target: Vector3, maxRadiansDelta: float, maxMagnitudeDelta: float) -> Vector3

Scale

static Scale(a: Vector3, b: Vector3) -> Vector3
Scale(scale: Vector3) -> void

Static. Multiplies two vectors component-wise.

let scaled: Vector3 = Vector3.Scale(size, multiplier)

Set

Set(newX: float, newY: float, newZ: float) -> void

SignedAngle

static SignedAngle(from: Vector3, to: Vector3, axis: Vector3) -> float

Slerp

static Slerp(a: Vector3, b: Vector3, t: float) -> Vector3

Static. Spherically interpolates between two vectors, useful for rotating directions smoothly.

let dir: Vector3 = Vector3.Slerp(from, to, t)

SlerpUnclamped

static SlerpUnclamped(a: Vector3, b: Vector3, t: float) -> Vector3

SmoothDamp

static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float, maxSpeed: float, deltaTime: float) -> Vector3
static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float, maxSpeed: float) -> Vector3
static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float) -> Vector3

SqrMagnitude

static SqrMagnitude(vector: Vector3) -> float

ToString

ToString() -> string
ToString(format: string, formatProvider: SystemIFormatProvider) -> string
ToString(format: string) -> string