Vector2
Overview
Description
The Vector2 class represents a mathematical 2D vector with x and y components. It is commonly used in game development or graphical applications for 2D position, direction, and mathematical operations.
Constructors
new
Creates a new instance of the Vector2 class with given x and y components.
Parameters
number x
The x-coordinate of the vector.
number y
The y-coordinate of the vector.
Return
Vector2
A new vector with the specified x and y coordinates.
Code Samples
local Vector = Vector2.new(3, 7)
print(Vector)Properties
X
number The x-coordinate of the vector.
Code Samples
local Vector = Vector2.new(5, 10)
print(Vector.X)Y
number The y-coordinate of the vector.
Code Samples
local Vector = Vector2.new(5, 10)
print(Vector.Y)zero
Vector2 A vector whose x and y components are both zero. Typically used to represent the origin or a null vector.
Code Samples
local ZeroVector = Vector2.zero
print(ZeroVector)one
Vector2 A vector whose x and y components are both set to 1.
Code Samples
local OneVector = Vector2.one
print(OneVector)xAxis
Vector2 A unit vector pointing in the x-axis direction (1, 0).
Code Samples
local XAxis = Vector2.xAxis
print(XAxis)yAxis
Vector2 A unit vector pointing in the y-axis direction (0, 1).
Code Samples
local YAxis = Vector2.yAxis
print(YAxis)Methods
Last updated