Optionalx: number | Vector2LikeThe x component, or an object with x and y properties. Default 0.
Optionaly: numberThe y component. Default x.
The x component of this Vector.
The y component of this Vector.
Static ReadonlyDOWNA static down Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Static ReadonlyLEFTA static left Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Static ReadonlyONEA static one Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Static ReadonlyRIGHTA static right Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Static ReadonlyUPA static up Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Static ReadonlyZEROA static zero Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
Add a given Vector to this Vector. Addition is component-wise.
The Vector to add to this Vector.
Calculate the angle between this Vector and the positive x-axis, in radians.
Make a clone of this Vector2.
Copy the components of a given Vector into this Vector.
The Vector to copy the components from.
Calculate the cross product of this Vector and the given Vector.
The Vector2 to cross with this Vector2.
Calculate the distance between this Vector and the given Vector.
The Vector to calculate the distance to.
Calculate the distance between this Vector and the given Vector, squared.
The Vector to calculate the distance to.
Perform a component-wise division between this Vector and the given Vector.
Divides this Vector by the given Vector.
The Vector to divide this Vector by.
Calculate the dot product of this Vector and the given Vector.
The Vector2 to dot product with this Vector2.
Check whether this Vector is equal to a given Vector.
Performs a strict equality check against each Vector's components.
The vector to compare with this Vector.
Check whether this Vector is approximately equal to a given Vector.
The vector to compare with this Vector.
Optionalepsilon: numberThe tolerance value. Default 0.0001.
Calculate the length (or magnitude) of this Vector.
Calculate the length of this Vector squared.
Linearly interpolate between this Vector and the given Vector.
Interpolates this Vector towards the given Vector.
The Vector2 to interpolate towards.
Optionalt: numberThe interpolation percentage, between 0 and 1. Default 0.
Limit the length (or magnitude) of this Vector.
The maximum length.
Perform a component-wise multiplication between this Vector and the given Vector.
Multiplies this Vector by the given Vector.
The Vector to multiply this Vector by.
Negate the x and y components of this Vector.
Normalize this Vector.
Makes the vector a unit length vector (magnitude of 1) in the same direction.
Rotate this Vector to its perpendicular, in the negative direction.
Rotate this Vector to its perpendicular, in the positive direction.
Make this Vector the zero vector (0, 0).
Rotate this Vector by an angle amount.
The angle to rotate by, in radians.
Scale this Vector by the given value.
The value to scale this Vector by.
Set the x and y components of the this Vector to the given x and y values.
The x value to set for this Vector.
Optionaly: numberThe y value to set for this Vector. Default x.
Set the component values of this Vector from a given Vector2Like object.
The object containing the component values to set for this Vector.
This method is an alias for Vector2.set.
The x value to set for this Vector.
Optionaly: numberThe y value to set for this Vector. Default x.
Sets the x and y values of this object from a given polar coordinate.
The angular coordinate, in radians.
Optionalradius: numberThe radial coordinate (length). Default 1.
Subtract the given Vector from this Vector. Subtraction is component-wise.
The Vector to subtract from this Vector.
A representation of a vector in 2D space.
A two-component vector.