Skip to content

API > Vector3


Vector3⚓︎

Representation of 3D vectors and points. Unity Vector3

Members⚓︎

Properties⚓︎

Name Description
Vector3.magnitudePropertyReadonly Property Returns the length of this vector (Read Only).
Vector3.normalizedPropertyReadonly Property Returns this vector with a magnitude of 1 (Read Only).
Vector3.sqrMagnitudePropertyReadonly Property Returns the squared length of this vector (Read Only).
Vector3.xProperty X component of the vector.
Vector3.yProperty Y component of the vector.
Vector3.zProperty Z component of the vector.

Static Properties⚓︎

Name Description
Vector3.back Static fieldPropertyReadonly Property Shorthand for writing Vector3(0, 0, -1).
Vector3.down Static fieldPropertyReadonly Property Shorthand for writing Vector3(0, -1, 0).
Vector3.forward Static fieldPropertyReadonly Property Shorthand for writing Vector3(0, 0, 1).
Vector3.left Static fieldPropertyReadonly Property Shorthand for writing Vector3(-1, 0, 0).
Vector3.negativeInfinity Static fieldPropertyReadonly Property Shorthand for writing Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity).
Vector3.one Static fieldPropertyReadonly Property Shorthand for writing Vector3(1, 1, 1).
Vector3.positiveInfinity Static fieldPropertyReadonly Property Shorthand for writing Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity).
Vector3.right Static fieldPropertyReadonly Property Shorthand for writing Vector3(1, 0, 0).
Vector3.up Static fieldPropertyReadonly Property Shorthand for writing Vector3(0, 1, 0).
Vector3.zero Static fieldPropertyReadonly Property Shorthand for writing Vector3(0, 0, 0).

Constructor⚓︎

Name Description
Vector3(x, y, z)Constructor Creates a new vector with given x, y, z components.

Methods⚓︎

Name Description
Vector3.Set(newX, newY, newZ) Method Set x, y and z components of an existing Vector3.

Static Methods⚓︎

Name Description
Vector3.Angle(from, to) Static fieldMethod Returns the angle in degrees between from and to.
Vector3.ClampMagnitude(vector, maxLength) Static fieldMethod Returns a copy of vector with its magnitude clamped to maxLength.
Vector3.Cross(lhs, rhs) Static fieldMethod Cross Product of two vectors.
Vector3.Distance(a, b) Static fieldMethod Returns the distance between a and b.
Vector3.Dot(lhs, rhs) Static fieldMethod Dot Product of two vectors.
Vector3.Lerp(a, b, t) Static fieldMethod Linearly interpolates between two points.
Vector3.LerpUnclamped(a, b, t) Static fieldMethod Linearly interpolates between two vectors.
Vector3.Max(lhs, rhs) Static fieldMethod Returns a vector that is made from the largest components of two vectors.
Vector3.Min(lhs, rhs) Static fieldMethod Returns a vector that is made from the smallest components of two vectors.
Vector3.MoveTowards(current, target, maxDistanceDelta) Static fieldMethod Calculate a position between the points specified by current and target, moving no farther than the distance specified by maxDistanceDelta.
Vector3.Normalize(value) Static fieldMethod Makes this vector have a magnitude of 1.
Vector3.Project(vector, onNormal) Static fieldMethod Projects a vector onto another vector.
Vector3.Reflect(inDirection, inNormal) Static fieldMethod Reflects a vector off the plane defined by a normal.
Vector3.RotateTowards(current, target, maxRadiansDelta, maxMagnitudeDelta) Static fieldMethod Rotates a vector current towards target.
Vector3.Scale(a, b) Static fieldMethod Multiplies two vectors component-wise.
Vector3.SignedAngle(from, to, axis) Static fieldMethod Returns the signed angle in degrees between from and to.
Vector3.Slerp(a, b, t) Static fieldMethod Spherically interpolates between two vectors.
Vector3.SlerpUnclamped(a, b, t) Static fieldMethod Spherically interpolates between two vectors.

Operators⚓︎

Name Description
Operator (Vector3-Vector3)Operator Subtracts one vector from another.

| Unary Operator (-Vector3)Operator | Negates a vector. Each component in the result is negated. |

| Operator (Vector3~=Vector3)Operator | Returns true if vectors are different. Very close vectors are treated as being equal. |

| Operator (Vector3*number)Operator | Multiplies a vector by a number. |

| Operator (number*Vector3)Operator | Multiplies a vector by a number. |

| Operator (Vector3/number)Operator | Divides a vector by a number. |

| Operator (Vector3+Vector3)Operator | Adds two vectors. |

| Operator (Vector3==Vector3)Operator | Returns true if two vectors are approximately equal. |