GetGroundZAndNormalFor3dCoord
Docslocal retval, groundZ, normal = GetGroundZAndNormalFor3dCoord(x, y, z)Description
Introduced in build 323
Attempts to identify the highest ground Z-coordinate and determine the corresponding surface normal directly beneath a specified 3D coordinate.
Parameters
| Name | Type | Description |
|---|---|---|
x | float | X-coordinate of the point to check. |
y | float | Y-coordinate of the point to check. |
z | float | Z-coordinate of the point to check. |
groundZ | float* | A pointer to a float where the ground Z-coordinate will be stored if found. |
normal | Vector3* | A pointer to a Vector3 structure where the surface normal at the ground point will be stored. |
Quick Snippet: Get Coordinatesxyznormal
xyznormalAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Returns
BOOLReturns TRUE (1) or FALSE (0).
Examples
Official
local x, y, z = 100.0, -200.0, 50.0
local success, groundZ, normal = GetGroundZAndNormalFor_3dCoord(x, y, z)
if success then
print("Ground Z found at: ", groundZ)
print("Surface normal is: ", normal.x, normal.y, normal.z)
else
print("No ground found.")
end