Description
The Vector2.Direction
method calculates the direction vector from one point to another in 2D space. This method is static and returns a Vector2
representing the direction from the from
vector to the to
vector. The direction vector is normalized, meaning it has a length of 1.
Usage
To use the Vector2.Direction
method, provide two Vector2
references as parameters. These references represent the starting and ending points in 2D space. The method will return a new Vector2
that points from the from
vector to the to
vector.
Example
Vector2 start = new Vector2(1, 2);
Vector2 end = new Vector2(4, 6);
Vector2 direction = Vector2.Direction(ref start, ref end);
// direction now holds the normalized vector pointing from start to end.