Skip to main content

Vector3

Representation of 3D vectors and points. Unity Vector3

Members

Properties

NameDescription
Vector3.magnitudeReturns the length of this vector (Read Only).
Vector3.normalizedReturns this vector with a magnitude of 1 (Read Only).
Vector3.sqrMagnitudeReturns the squared length of this vector (Read Only).
Vector3.xX component of the vector.
Vector3.yY component of the vector.
Vector3.zZ component of the vector.

Static Properties

NameDescription
Vector3.backShorthand for writing Vector3(0, 0, -1).
Vector3.downShorthand for writing Vector3(0, -1, 0).
Vector3.forwardShorthand for writing Vector3(0, 0, 1).
Vector3.leftShorthand for writing Vector3(-1, 0, 0).
Vector3.negativeInfinityShorthand for writing Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity).
Vector3.oneShorthand for writing Vector3(1, 1, 1).
Vector3.positiveInfinityShorthand for writing Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity).
Vector3.rightShorthand for writing Vector3(1, 0, 0).
Vector3.upShorthand for writing Vector3(0, 1, 0).
Vector3.zeroShorthand for writing Vector3(0, 0, 0).

Constructor

NameDescription
Vector3(x, y, z)Creates a new vector with given x, y, z components.

Methods

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

Static Methods

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

Operators

NameDescription
Operator (Vector3-Vector3)Subtracts one vector from another.

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

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

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

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

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

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

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