Defines and returns a vector's Cartesian coordinates.
x, y = vector:GetXY() x, y, z = vector:GetXYZ() vector:SetXY(x, y) vector:SetXYZ(x, y, z)
- x, y, z
- number - Cartesian coordinates.
- Vector2DMixin uses GetXY() and SetXY().
- Vector3DMixin uses GetXYZ() and SetXYZ().
- Despite similarities, these two mixins are not compatible with each other. They must be manually converted or projected by copying coordinate values from one type to another.
Manually converting a 2D vector to 3D:
local x, y = vector2d:GetXY() local vector3d = CreateFromMixins(Vector3DMixin) vector3d:SetXYZ(x, y, 0)
Manually projecting a 3D vector to 2D:
local x, y, z = vector3d:GetXYZ() local vector2d = CreateFromMixins(Vector2DMixin) vector3d:SetXY(x, y)
- CreateVector2D(x,y) - Creates a new vector and applies SetXY.
- CreateVector3D(x,y,z) - Creates a new vector and applies SetXYZ.