Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Runtime classServer APIGenerated

Vector2

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

Mutable two-dimensional vector.

new Vector2(x, y): Vector2

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

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:7622

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:7685

Creates an independent copy of this vector.

Vector2

New vector with the same components.


distance(other): number

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

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:7643

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:7650

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:7664

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:7636

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:7656

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:7672

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:7629

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:7697

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:7691

Formats this vector for logging and debugging.

string

Text in Vector2(x, y) form.


static one(): Vector2

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

Creates a vector whose components are one.

Vector2

New Vector2(1, 1).


static zero(): Vector2

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

Creates a vector whose components are zero.

Vector2

New Vector2(0, 0).

readonly length: number

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

Read-only Euclidean magnitude of this vector.


readonly lengthSquared: number

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

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


x: number

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

Mutable X component.


y: number

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

Mutable Y component.