Vector2

A 2D vector: a position or a size on a screen.

Add, subtract and scale it, and read its length and direction.

Constructors

Up and coming: the native runtime gives these. Today a program reads a Vector2 from an attribute, and shot check refuses Vector2.new in a System project.

NameArgumentsReturnsDescription
Vector2.new(x: number?, y: number?)Vector2

Constants

NameTypeDescription
Vector2.zeroVector2
Vector2.oneVector2

Properties

NameTypeDefaultDescription
Magnitudenumber
UnitVector2
Xnumber
Ynumber

Methods

NameArgumentsReturnsDescription
Abs()Vector2
Angle(other: Vector2, isSigned: boolean?)number
Ceil()Vector2
Cross(other: Vector2)number
Dot(v: Vector2)number
Floor()Vector2
FuzzyEq(other: Vector2, epsilon: number?)boolean
Lerp(v: Vector2, alpha: number)Vector2
Max(...: Vector2)Vector2
Min(...: Vector2)Vector2
Sign()Vector2

Operators