Skip to content
M2O Scripting APIScripting reference
Runtime classClient APIGenerated

Vector2

Defined in: client/api.d.ts:1311

Mutable two-dimensional vector exposed as Core.Vector2.

new Vector2(x, y): Vector2

Defined in: client/api.d.ts:1317

Creates a vector from two numeric components.

number

Initial X component.

number

Initial Y component.

Vector2

add(other): this

Defined in: client/api.d.ts:1344

Adds another vector to this vector in place.

Vector2

Vector to add component-wise.

this

This mutated vector for chaining.


clone(): Vector2

Defined in: client/api.d.ts:1407

Creates an independent copy of this vector.

Vector2

New vector with the same components.


distance(other): number

Defined in: client/api.d.ts:1401

Computes Euclidean distance to another vector.

Vector2

Vector to measure from this vector.

number

Distance between the two vectors.


div(scalar): this

Defined in: client/api.d.ts:1365

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: client/api.d.ts:1372

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: client/api.d.ts:1386

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: client/api.d.ts:1358

Multiplies this vector by a scalar in place.

number

Multiplier applied to both components.

this

This mutated vector for chaining.


normalize(): this

Defined in: client/api.d.ts:1378

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

this

This mutated vector for chaining.


set(x, y): this

Defined in: client/api.d.ts:1394

Replaces both components in place.

number

Replacement X component.

number

Replacement Y component.

this

This mutated vector for chaining.


sub(other): this

Defined in: client/api.d.ts:1351

Subtracts another vector from this vector in place.

Vector2

Vector to subtract component-wise.

this

This mutated vector for chaining.


toJSON(): object

Defined in: client/api.d.ts:1419

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

object

Object containing the current components.

x: number

y: number


toString(): string

Defined in: client/api.d.ts:1413

Formats this vector for logging and debugging.

string

Text in Vector2(x, y) form.


static one(): Vector2

Defined in: client/api.d.ts:1431

Creates a vector whose components are one.

Vector2

New Vector2(1, 1).


static zero(): Vector2

Defined in: client/api.d.ts:1425

Creates a vector whose components are zero.

Vector2

New Vector2(0, 0).

readonly length: number

Defined in: client/api.d.ts:1332

Read-only Euclidean magnitude of this vector.


readonly lengthSquared: number

Defined in: client/api.d.ts:1337

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


x: number

Defined in: client/api.d.ts:1322

Mutable X component.


y: number

Defined in: client/api.d.ts:1327

Mutable Y component.