Vector3
Three-component vector type used for positions, sizes, directions and rotations.
Y is the up axis. One unit is one stud.
local spawn = Vector3.new(0, 5, 0)
local inFront = character.Position + character.LookVector * 5
local distance = (part.Position - character.Position).Magnitude| Operator | Result |
|---|---|
a + b, a - b | Component-wise addition or subtraction. |
a * 2, a / 2 | Scalar multiplication or division. |
a * b | Component-wise multiplication. |
a == b | true if every component is equal within a small tolerance. |
Constructors
new
Vector3.new(x: number, y: number, z: number): Vector3Constructs a vector. The constants Vector3.zero and Vector3.one are also available.
Properties
X
vector.X: numberX component. Y and Z are also available.
Magnitude
vector.Magnitude: numberEuclidean length.
Unit
vector.Unit: Vector3Normalized copy with a magnitude of 1.
Methods
Dot
a:Dot(b: Vector3): numberReturns the dot product of a and b.
Cross
a:Cross(b: Vector3): Vector3Returns the cross product of a and b.
Lerp
a:Lerp(b: Vector3, amount: number): Vector3Linearly interpolates from a to b by amount. 0 returns a and 1 returns b.