Skip to content
M2O Scripting APIScripting reference
Global objectClient APIGenerated

World

const World: object

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

Client-side queries against the currently streamed Mafia II world.

getGroundZ(x, y, z, maxDistance?): number | null

Finds the closest ground surface below a world-space position using the game physics scene.

number

World-space X coordinate of the ray origin.

number

World-space Y coordinate of the ray origin.

number

World-space Z coordinate from which to search downward.

number

Maximum downward probe distance in world units; defaults to 200.

number | null

The ground Z coordinate, or null when no surface is found, physics is unavailable, or maxDistance is not positive.

raycast(from, to, options?): RaycastHit | null

Casts a ray through the streamed physics scene and returns the closest surface it hits, so anything behind a wall is never reported. Only collision is hit: geometry without collision and areas not yet streamed in are invisible to it.

Vector3

World-space ray start.

Vector3

World-space ray end.

RaycastOptions

Optional filters.

RaycastHit | null

The closest hit, or null when nothing was hit or physics is unavailable.

const hit = World.raycast(from, to);
if (hit && hit.type === "vehicle") {
// hit.entity is the Vehicle, hit.networkId its id.
}