Vector3¶
Global · Vector3 · server and client scripts
Vector3 creates 3D vectors for positions, directions and sizes, in units. A vector is a Luau vector: read X, Y and Z, its length as Magnitude and its direction as Unit, and call :Dot, :Cross and :Lerp with a colon. Arithmetic works one component at a time, and * and / also scale by a number. Luau's vector library works on these values too; read Unit rather than vector.normalize when a vector can be zero, because Vector3.Zero.Unit is Vector3.Zero while vector.normalize(Vector3.Zero) is NaN.
Example
new¶
Vector3.new creates a vector from x, y and z.
Zero¶
Vector3.Zero is the vector with every component 0.
Default Vector3.new(0, 0, 0)
One¶
Vector3.One is the vector with every component 1.
Default Vector3.new(1, 1, 1)
XAxis¶
Vector3.XAxis is the unit vector along +X.
Default Vector3.new(1, 0, 0)
YAxis¶
Vector3.YAxis is the unit vector along +Y, which points up.
Default Vector3.new(0, 1, 0)
ZAxis¶
Vector3.ZAxis is the unit vector along +Z.
Default Vector3.new(0, 0, 1)