Vector2 is a 2D vector with x, y components. You’ll encounter it
primarily as the return type of
Math.worldToScreen - screen-space pixel
coordinates for ESP overlays and HUD elements.
Unlike Vector, Vector2 has no z component.
Operations like
mul and div accept both a scalar number and another
Vector2 - check the overloads below.Overview
Creating vectors
Numbers, arrays, objects, or axis presets.
Arithmetic
Add, subtract, multiply, divide - all return new instances.
Length & distance
Magnitude and distance on the 2D plane.
Products
Dot product, 2D cross product.
Transforms
Normalize, rotate, absolute value.
Utility
Clone, convert to array, string output.
Properties
Creating vectors
Constructor
0.
- Numbers
- Array
- Object
Vector2.zero
(0, 0) vector.
Vector2.one
(1, 1) vector.
Vector2.xAxis
(1, 0) - the horizontal unit vector.
Vector2.yAxis
(0, 1) - the vertical unit vector.
Arithmetic
All arithmetic methods return a new Vector2.add
sub
mul
div
Length & distance
length
√(x² + y²).
lengthSqr
x² + y². Faster for comparisons.
distTo
Products
dot
x*ox + y*oy.
cross
other is counter-clockwise
from vec, negative = clockwise.
In 3D the cross product returns a vector. In 2D it returns a scalar -
the z-component of what the 3D cross would be. This is different
from Vector.cross.
Transforms
normalize
this.
normalized
rotate
degrees around the origin. Returns a new
Vector2. Positive = counter-clockwise.
- Indicator offset
- Rotated HUD
abs
Utility
clone
toArray
[x, y] as a plain array.
toString
Common patterns
- ESP label offset
- Screen-space box
- Circle indicator
- Normalized screen coords