Skip to content
M2O Scripting APIScripting reference
Runtime classServer APIGenerated

Vector2

Defined in: server/api.d.ts:1894

Mutable two-dimensional vector exposed as Core.Vector2.

new Vector2(x, y): Vector2

Defined in: server/api.d.ts:1900

Creates a vector from two numeric components.

number

Initial X component.

number

Initial Y component.

Vector2

add(other): this

Defined in: server/api.d.ts:1927

Adds another vector to this vector in place.

Vector2

Vector to add component-wise.

this

This mutated vector for chaining.


clone(): Vector2

Defined in: server/api.d.ts:1990

Creates an independent copy of this vector.

Vector2

New vector with the same components.


distance(other): number

Defined in: server/api.d.ts:1984

Computes Euclidean distance to another vector.

Vector2

Vector to measure from this vector.

number

Distance between the two vectors.


div(scalar): this

Defined in: server/api.d.ts:1948

Divides this vector by a scalar in place.

number

Divisor applied to both components; must be non-zero.

this

This mutated vector for chaining.


dot(other): number

Defined in: server/api.d.ts:1955

Computes the dot product without changing either vector.

Vector2

Vector used for the dot product.

number

Scalar dot product.


lerp(target, t): this

Defined in: server/api.d.ts:1969

Linearly interpolates this vector toward a target in place.

Vector2

Destination vector.

number

Interpolation factor; 0 keeps the current value and 1 reaches target.

this

This mutated vector for chaining.


mul(scalar): this

Defined in: server/api.d.ts:1941

Multiplies this vector by a scalar in place.

number

Multiplier applied to both components.

this

This mutated vector for chaining.


normalize(): this

Defined in: server/api.d.ts:1961

Normalizes this vector in place; a zero vector remains unchanged.

this

This mutated vector for chaining.


set(x, y): this

Defined in: server/api.d.ts:1977

Replaces both components in place.

number

Replacement X component.

number

Replacement Y component.

this

This mutated vector for chaining.


sub(other): this

Defined in: server/api.d.ts:1934

Subtracts another vector from this vector in place.

Vector2

Vector to subtract component-wise.

this

This mutated vector for chaining.


toJSON(): object

Defined in: server/api.d.ts:2002

Converts this vector to a plain object for JSON.stringify.

object

Object containing the current components.

x: number

y: number


toString(): string

Defined in: server/api.d.ts:1996

Formats this vector for logging and debugging.

string

Text in Vector2(x, y) form.


static one(): Vector2

Defined in: server/api.d.ts:2014

Creates a vector whose components are one.

Vector2

New Vector2(1, 1).


static zero(): Vector2

Defined in: server/api.d.ts:2008

Creates a vector whose components are zero.

Vector2

New Vector2(0, 0).

readonly length: number

Defined in: server/api.d.ts:1915

Read-only Euclidean magnitude of this vector.


readonly lengthSquared: number

Defined in: server/api.d.ts:1920

Read-only squared magnitude, avoiding a square-root calculation.


x: number

Defined in: server/api.d.ts:1905

Mutable X component.


y: number

Defined in: server/api.d.ts:1910

Mutable Y component.