Skip to content

Vector2

Vector2 is a 2D vector with an x and y component.

Not newable

This object cannot be created by scripts using Instance.New().

Properties

X : number

The X component of the vector.

Y : number

The Y component of the vector.

Down : Vector2

Shorthand for Vector2.New(0, -1).

Left : Vector2

Shorthand for Vector2.New(-1, 0).

One : Vector2

Shorthand for Vector2.New(1, 1).

Zero : Vector2

Shorthand for Vector2.New(0, 0).

Shorthand for Vector2.New(1, 0).

Up : Vector2

Shorthand for Vector2.New(0, 1).

Magnitude : number

The length of the vector.

Normalized : Vector2

The normalized version of the vector.

SqrMagnitude : number

The squared length of the vector.

Methods

New → Vector2

Parameters: ``

Returns a new Vector2 with the given x and y components.

New → Vector2

Parameters: d [ number ]

Returns a new Vector2 with the given x and y components.

New → Vector2

Parameters

x [ number ]

y [ number ]

Returns a new Vector2 with the given x and y components.

Angle → number

Parameters

from [ Vector2 ]

to [ Vector2 ]

Returns the angle in degrees between from and to.

Cross → Vector2

Parameters

lhs [ Vector2 ]

rhs [ Vector2 ]

Returns the cross product of lhs and rhs.

Distance → number

Parameters

a [ Vector2 ]

b [ Vector2 ]

Returns the distance between a and b.

Dot → number

Parameters

lhs [ Vector2 ]

rhs [ Vector2 ]

Returns the dot product of lhs and rhs.

Lerp → Vector2

Parameters

a [ Vector2 ]

b [ Vector2 ]

t [ number ]

Returns a new vector that is the linear interpolation between a and b by t.

Max → Vector2

Parameters

lhs [ Vector2 ]

rhs [ Vector2 ]

Returns a vector that is made from the largest components of two vectors.

Min → Vector2

Parameters

lhs [ Vector2 ]

rhs [ Vector2 ]

Returns a vector that is made from the smallest components of two vectors.

MoveTowards → Vector2

Parameters

current [ Vector2 ]

target [ Vector2 ]

maxDistanceDelta [ number ]

Calculate a position between the points specified by current and target, moving no farther than the distance specified by maxDistanceDelta.

Normalize → Vector2

Parameters: value [ Vector2 ]

Returns a new Vector2 that is the normalized version of the given vector.

Project → Vector2

Parameters

vector [ Vector2 ]

onNormal [ Vector2 ]

Returns the projection of a vector onto another vector.

Reflect → Vector2

Parameters

inDirection [ Vector2 ]

inNormal [ Vector2 ]

Returns the reflection of a vector off the plane defined by a normal.

Slerp → Vector2

Parameters

a [ Vector2 ]

b [ Vector2 ]

t [ number ]

Spherically interpolates between two vectors.