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
| Property | Type | Access |
|---|---|---|
| back | Vector3 | get |
| down | Vector3 | get |
| forward | Vector3 | get |
| Item | float | get, set |
| kEpsilon | float | get |
| kEpsilonNormalSqrt | float | get |
| left | Vector3 | get |
| magnitude | float | get |
| negativeInfinity | Vector3 | get |
| normalized | Vector3 | get |
| one | Vector3 | get |
| positiveInfinity | Vector3 | get |
| right | Vector3 | get |
| sqrMagnitude | float | get |
| up | Vector3 | get |
| x | float | get, set |
| y | float | get, set |
| z | float | get, set |
| zero | Vector3 | get |
back
Static. Shorthand for Vector3(0, 0, -1).
let bk: Vector3 = Vector3.backdown
Static. Shorthand for Vector3(0, -1, 0).
let downward: Vector3 = Vector3.downforward
Static. Shorthand for Vector3(0, 0, 1).
let fwd: Vector3 = Vector3.forwardleft
Static. Shorthand for Vector3(-1, 0, 0).
let l: Vector3 = Vector3.leftmagnitude
The length of this vector.
let speed: float = velocity.magnitudenormalized
Returns this vector with a magnitude of 1, preserving direction.
let dir: Vector3 = offset.normalizedone
Static. Shorthand for Vector3(1, 1, 1).
transform.localScale = Vector3.oneright
Static. Shorthand for Vector3(1, 0, 0).
let r: Vector3 = Vector3.rightup
Static. Shorthand for Vector3(0, 1, 0).
let upward: Vector3 = Vector3.upx
The X (horizontal / red axis) component.
let horizontal: float = pos.xy
The Y (vertical / green axis) component.
let height: float = pos.yz
The Z (depth / blue axis) component.
let depth: float = pos.zzero
Static. Shorthand for Vector3(0, 0, 0).
transform.localPosition = Vector3.zeroMethods
Angle
static Angle(from: Vector3, to: Vector3) -> floatStatic. Returns the angle in degrees between two vectors.
let angle: float = Vector3.Angle(a, b)ClampMagnitude
static ClampMagnitude(vector: Vector3, maxLength: float) -> Vector3Cross
static Cross(lhs: Vector3, rhs: Vector3) -> Vector3Static. Returns the cross product of two vectors (perpendicular vector).
let normal: Vector3 = Vector3.Cross(a, b)Distance
static Distance(a: Vector3, b: Vector3) -> floatStatic. Returns the distance between two points.
let dist: float = Vector3.Distance(a, b)Dot
static Dot(lhs: Vector3, rhs: Vector3) -> floatStatic. Returns the dot product of two vectors. Positive when facing similar directions.
let alignment: float = Vector3.Dot(forward, toTarget)Equals
Equals(other: object) -> boolEquals(other: Vector3) -> boolGetHashCode
GetHashCode() -> intGetType
GetType() -> SystemTypeLerp
static Lerp(a: Vector3, b: Vector3, t: float) -> Vector3Static. 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) -> Vector3Magnitude
static Magnitude(vector: Vector3) -> floatMax
static Max(lhs: Vector3, rhs: Vector3) -> Vector3Min
static Min(lhs: Vector3, rhs: Vector3) -> Vector3MoveTowards
static MoveTowards(current: Vector3, target: Vector3, maxDistanceDelta: float) -> Vector3Static. 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) -> Vector3static new(x: float, y: float) -> Vector3Normalize
Normalize() -> voidstatic Normalize(value: Vector3) -> Vector3Static. Returns the given vector with magnitude 1.
let unit: Vector3 = Vector3.Normalize(direction)OrthoNormalize
static OrthoNormalize(normal: Vector3, tangent: Vector3, binormal: Vector3) -> Vector3static OrthoNormalize(normal: Vector3, tangent: Vector3) -> Vector3Project
static Project(vector: Vector3, onNormal: Vector3) -> Vector3ProjectOnPlane
static ProjectOnPlane(vector: Vector3, planeNormal: Vector3) -> Vector3Reflect
static Reflect(inDirection: Vector3, inNormal: Vector3) -> Vector3RotateTowards
static RotateTowards(current: Vector3, target: Vector3, maxRadiansDelta: float, maxMagnitudeDelta: float) -> Vector3Scale
static Scale(a: Vector3, b: Vector3) -> Vector3Scale(scale: Vector3) -> voidStatic. Multiplies two vectors component-wise.
let scaled: Vector3 = Vector3.Scale(size, multiplier)Set
Set(newX: float, newY: float, newZ: float) -> voidSignedAngle
static SignedAngle(from: Vector3, to: Vector3, axis: Vector3) -> floatSlerp
static Slerp(a: Vector3, b: Vector3, t: float) -> Vector3Static. 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) -> Vector3SmoothDamp
static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float, maxSpeed: float, deltaTime: float) -> Vector3static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float, maxSpeed: float) -> Vector3static SmoothDamp(current: Vector3, target: Vector3, currentVelocity: Vector3, smoothTime: float) -> Vector3SqrMagnitude
static SqrMagnitude(vector: Vector3) -> floatToString
ToString() -> stringToString(format: string, formatProvider: SystemIFormatProvider) -> stringToString(format: string) -> string