PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

Vector2

Vector2

In Roblox, the Vector2 datatype is often used in working with GUI elements and 2D mouse positions.

Constructors

Vector2.new ( number x, number y )

Creates a new Vector2 using ordinates x and y

Properties

number Vector2.X

The x-coordinate

number Vector2.Y

The y-coordinate

number Vector2.Magnitude

The length of the vector

Vector2 Vector2.Unit

A normalized copy of the vector

Functions

Vector2 Vector2:Lerp ( Vector2 v, number alpha )

Returns a Vector2 linearly interpolated between this Vector2 and v by the fraction alpha

number Vector2:Dot ( Vector2 v )

Returns a scalar dot product of the two vectors

number Vector2:Cross ( Vector2 other )

Returns the cross product of the two vectors

Math Operations

Vector2 Vector2 + Vector2

Returns a new Vector2 with each component of the second added to the corresponding component of the first.

Vector2 Vector2 - Vector2

Returns a new Vector2 with each component of the second subtracted from the corresponding component of the first.

Vector2 Vector2 * Vector2

Returns a new Vector2 with each component of the second multiplied the corresponding component of the first.

Vector2 Vector2 / Vector2

Returns a new Vector2 with each component of the first divided by the corresponding component of the second.

Vector2 Vector2 * number

Returns the Vector2 with each component multiplied by the number.

Vector2 Vector2 / number

Returns the Vector2 with each component divided by the number.