Vector2

Overview

Vector2 is a data type used to express vector in a two-dimensional space using X and Y axes. It is used to handle a variety of 2D data such as position, direction, speed, and strength. It is also one of the key elements used by many systems to calculate coordinates and vector within a space or simulating 2D physics.

Constructors

new

Creates and returns a new vector using the passed X and Y values.

Parameters

number x

The value of X coordinate.

number y

The value of Y coordinate.

Return

Vector2

The created Vector2.

Code Samples

local Vector = Vector2.new(3, 7)
print(Vector)

Properties

X

number

The value of X coordinate.

Code Samples

Y

number

The value of Y coordinate.

Code Samples

zero

Vector2

A vector of which axis values are zeroes (0, 0).

Code Samples

one

Vector2

A vector of which axis values are ones (1, 1).

Code Samples

xAxis

Vector2

A Vector2 set to have the value of 1 for X axis and 0 for Y axis (1, 0).

Code Samples

yAxis

Vector2

A Vector2 set to have the value of 0 for X axis and 1 for Y axis (0, 1).

Code Samples

Methods

Last updated