World
constWorld:object
Defined in: client/api.d.ts:1497
Client-side queries against the currently streamed Mafia II world.
Type Declaration
Section titled “Type Declaration”getGroundZ()
Section titled “getGroundZ()”getGroundZ(
x,y,z,maxDistance?):number|null
Finds the closest ground surface below a world-space position using the game physics scene.
Parameters
Section titled “Parameters”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.
maxDistance?
Section titled “maxDistance?”number
Maximum downward probe distance in world units; defaults to 200.
Returns
Section titled “Returns”number | null
The ground Z coordinate, or null when no surface is found, physics is unavailable, or maxDistance is not positive.
raycast()
Section titled “raycast()”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.
Parameters
Section titled “Parameters”World-space ray start.
World-space ray end.
options?
Section titled “options?”Optional filters.
Returns
Section titled “Returns”RaycastHit | null
The closest hit, or null when nothing was hit or physics is unavailable.
Example
Section titled “Example”const hit = World.raycast(from, to);if (hit && hit.type === "vehicle") { // hit.entity is the Vehicle, hit.networkId its id.}