# MISC::_GET_GROUND_Z_AND_MATERIAL_FOR_3D_COORD

- **Hash:** `0xBBE5B63EFFB08E68`
- **Namespace:** MISC
- **Runtime name (Lua/JS):** `GetGroundZAndMaterialFor_3dCoord`
- **Side:** client (game native)
- **Name status:** community guess (may change)
- **Documentation:** described
- **Since game build:** 1207
- **URL:** https://natives.borderlinerp.com/natives/MISC/_GET_GROUND_Z_AND_MATERIAL_FOR_3D_COORD

## Signature

```c
BOOL _GET_GROUND_Z_AND_MATERIAL_FOR_3D_COORD(float x, float y, float z, int flags, float* outGroundZ, Hash* outMaterialHash, int* outFlags);
```

## Parameters

- `x` (`float`)
- `y` (`float`)
- `z` (`float`)
- `flags` (`int`)
- `outGroundZ` (`float*`)
- `outMaterialHash` (`Hash*`)
- `outFlags` (`int*`)

## Returns

`BOOL`

## Description

*Source: alloc8or RDR3 NativeDB*

Raycasts downward from coords to find terrain/water.

- flags: collision mask (R* scripts commonly use 17, 129, or 3423).
- outGroundZ: receives the hit Z.
- outMaterialHash: receives the surface/material hash.
- outFlags: receives hit flags (bitfield; water/special cases may set bits).

Returns true on hit, false otherwise.

*Source: VORPCORE RDR3natives*

Outputs the ground Z axis, its material and flags.Input flags are 17, 129 or 3423 in R* scripts.similar to flags of shapes test native

## Usage

### Lua

```lua
local retval, outGroundZ, outMaterialHash, outFlags = GetGroundZAndMaterialFor_3dCoord(x, y, z, flags)

-- always available, by hash
local retval, outGroundZ, outMaterialHash, outFlags = Citizen.InvokeNative(0xBBE5B63EFFB08E68, x, y, z, flags, Citizen.PointerValueFloat(), Citizen.PointerValueInt(), Citizen.PointerValueInt(), Citizen.ReturnResultAnyway())
```

### JavaScript

```js
const [retval, outGroundZ, outMaterialHash, outFlags] = GetGroundZAndMaterialFor_3dCoord(x, y, z, flags);

// by hash
const [retval, outGroundZ, outMaterialHash, outFlags] = Citizen.invokeNative('0xBBE5B63EFFB08E68', x + 0.0000001, y + 0.0000001, z + 0.0000001, flags, Citizen.pointerValueFloat(), Citizen.pointerValueInt(), Citizen.pointerValueInt(), Citizen.returnResultAnyway());
```

### C#

```csharp
var outGroundZ = new OutputArgument();
var outMaterialHash = new OutputArgument();
var outFlags = new OutputArgument();
bool retval = Function.Call<bool>((Hash)0xBBE5B63EFFB08E68, x, y, z, flags, outGroundZ, outMaterialHash, outFlags);
// outGroundZ.GetResult<float>()
// outMaterialHash.GetResult<int>()
// outFlags.GetResult<int>()
```

- Float parameters: Lua integers (`10`, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write `10.0` or `value + 0.0`. The generated JS wrappers add `0.0000001` to non-zero floats for the same reason.
- Pointer (out) arguments are not passed in Lua/JS: their values are returned after the result, in order.
- The name is a community guess and may change. If the named call is missing in your client build, use `InvokeNative` with the hash — it always works.

*Sources: alloc8or RDR3 NativeDB, VORPCORE RDR3natives.*
