Lua API
On this page

Vector2

Tip

This is a builtin dotnet type. The documentation and api interface are generated from dotnet source files.

Represents a vector with two single-precision floating-point values.

Fields:

One Vector2

staticread only

Gets a vector whose 2 elements are equal to one.

UnitX Vector2

staticread only

Gets the vector (1,0).

UnitY Vector2

staticread only

Gets the vector (0,1).

X number

The X component of the vector.

Y number

The Y component of the vector.

Zero Vector2

staticread only

Returns a vector whose 2 elements are equal to zero.

Constructors:

New(value: number) :

Creates a new Vector2 object whose two elements have the same value.

Parameters:
NameTypeDefaultSummary
valuenumber

The value to assign to both elements.

New(x: number, y: number) :

Creates a vector whose elements have the specified values.

Parameters:
NameTypeDefaultSummary
xnumber

The value to assign to the Vector2.X field.

ynumber

The value to assign to the Vector2.Y field.

Methods:

Abs(value: Vector2) : Vector2

static

Returns a vector whose elements are the absolute values of each of the specified vector's elements.

Parameters:
NameTypeDefaultSummary
valueVector2

A vector.

Returns:Vector2

Add(left: Vector2, right: Vector2) : Vector2

static

Adds two vectors together.

Parameters:
NameTypeDefaultSummary
leftVector2

The first vector to add.

rightVector2

The second vector to add.

Returns:Vector2

Clamp(value1: Vector2, min: Vector2, max: Vector2) : Vector2

static

Restricts a vector between a minimum and a maximum value.

Parameters:
NameTypeDefaultSummary
value1Vector2

The vector to restrict.

minVector2

The minimum value.

maxVector2

The maximum value.

Returns:Vector2

CopyTo(array: number, index: number) : nil

Copies the elements of the vector to a specified array starting at a specified index position.

Parameters:
NameTypeDefaultSummary
arraynumber

The destination array.

indexnumber

The index at which to copy the first element of the vector.

Returns:nil

CopyTo(array: number) : nil

Copies the elements of the vector to a specified array.

Parameters:
NameTypeDefaultSummary
arraynumber

The destination array.

Returns:nil

Distance(value1,value2) value1 Vector2 , value2 Vector2

DistanceSquared(value1,value2) value1 Vector2 , value2 Vector2

Divide(left,divisor) left Vector2 , divisor number

Divide(left,right) left Vector2 , right Vector2

Dot(value1,value2) value1 Vector2 , value2 Vector2

Length()

LengthSquared()

Lerp(value1,value2,amount) value1 Vector2 , value2 Vector2 , amount number

Max(value1,value2) value1 Vector2 , value2 Vector2

Min(value1,value2) value1 Vector2 , value2 Vector2

Multiply(left,right) left Vector2 , right Vector2

Multiply(left,right) left Vector2 , right number

Multiply(left,right) left number , right Vector2

Negate(value) value Vector2

Normalize(value) value Vector2

Reflect(vector,normal) vector Vector2 , normal Vector2

SquareRoot(value) value Vector2

Subtract(left,right) left Vector2 , right Vector2

ToString()

ToString(format) format string

Transform(position,matrix) position Vector2 , matrix Matrix3x2

Transform(position,matrix) position Vector2 , matrix Matrix4x4

Transform(value,rotation) value Vector2 , rotation Quaternion

TransformNormal(normal,matrix) normal Vector2 , matrix Matrix3x2

TransformNormal(normal,matrix) normal Vector2 , matrix Matrix4x4