Vector2
Client-side
 Server-side
 Shared
 Element category: Vector
This is a 2D Vector class.
OOP-Only Methods
create
Default constructor for the Vector2 class. Returns a Vector2 object.
Vector2(mixed vectorOrX[, float y])- vectorOrX: float | table | vector2– Vector2, table, or float indicating vector's coordinates
- y: float– If vectorOrX is a float, this is the Y coordinate
normalize
Normalizes the vector
bool Vector2.normalize(vector2 vector)- vector: vector2– Vector2 to normalize
getX
Gets the X coordinate of a vector
float Vector2.getX(vector2 vector)- vector: vector2– Vector2 to get X coordinate from
getY
Gets the Y coordinate of a vector
float Vector2.getY(vector2 vector)- vector: vector2– Vector2 to get Y coordinate from
setX
Sets the X coordinate of a vector
bool Vector2.setX(vector2 vector, float x)- vector: vector2– Vector2 to set X coordinate on
- x: float– New X coordinate
setY
Sets the Y coordinate of a vector
bool Vector2.setY(vector2 vector, float y)- vector: vector2– Vector2 to set Y coordinate on
- y: float– New Y coordinate
getNormalized
Gets a normalized version of the vector
vector2 Vector2.getNormalized(vector2 vector)- vector: vector2– Vector2 to get normalized version of
getLength
Gets the length of a vector
float Vector2.getLength(vector2 vector)- vector: vector2– Vector2 to get length from
getSquaredLength
Gets the squared length of a vector
float Vector2.getSquaredLength(vector2 vector)- vector: vector2– Vector2 to get squared length from
dot
Gets the dot product of two vectors
float Vector2.dot(vector2 vectorOne, vector2 vectorTwo)- vectorOne: vector2– First vector
- vectorTwo: vector2– Second vector
Code Examples
 client   
 Checks if the player is using a low resolution
addEventHandler ( "onClientResourceStart", resourceRoot, function()    local screenSize = Vector2(guiGetScreenSize())    if screenSize.x < 1360 and screenSize.y < 768 then        outputChatBox ("You are running on a low resolution")    endend) 
 