Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Normalize

Creates a normalized copy of the given vector.
Read time 2 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

Normalize(Vector3)

Creates a normalized copy of the given vector.
public static Vector3 Normalize(Vector3 value)

Parameters

value

The vector to be normalized.

Returns

Type

Description

Vector3A new vector with the same direction as the original vector but with a magnitude of 1.0.

Remarks

Returns a normalized vector based on the given vector. The normalized vector has a Vector3.magnitude of 1 and is in the same direction as the given vector.
The vector components can be positive or negative. After normalization, the vector lies on the unit sphere, so its length is 1, and each component can be anywhere between −1 and 1 depending on direction.
If the given vector is too small to be normalized, then this function returns the zero vector. A vector is too small to be normalized if it is considered equal to the zero vector.
Note: This method doesn't modify the given vector. To modify and normalize the current vector, use the instance version of this method, with no parameter.
Additional Resources: Vector3.normalized.

Normalize()

Normalizes the magnitude of the current vector to 1 while maintaining the direction.
public void Normalize()

Remarks

This method converts the current vector to a unit vector. The converted vector has a Vector3.magnitude of 1 and is in the same direction. Only the magnitude of the vector changes.
The vector components can be positive or negative. After normalization, the vector lies on the unit sphere, so its length is 1, and each component can be anywhere between −1 and 1 depending on direction.
If the current vector is too small to be normalized, then this method sets the current vector to the zero vector. A vector is too small to be normalized if it is considered equal to the zero vector.
Note: This method changes the current vector. If you want to keep the current vector unchanged, use Vector3.normalized variable or the static version of this method.
Additional Resources: Vector3.normalized.