# CFX::GET_WORLD_COORD_FROM_SCREEN_COORD

- **Hash:** `0xC81D0659`
- **Namespace:** CFX
- **Runtime name (Lua/JS):** `GetWorldCoordFromScreenCoord`
- **Side:** client (Cfx runtime native)
- **Name status:** official
- **Documentation:** described with examples
- **URL:** https://natives.borderlinerp.com/natives/CFX/GET_WORLD_COORD_FROM_SCREEN_COORD

## Signature

```c
void GET_WORLD_COORD_FROM_SCREEN_COORD(float screenX, float screenY, Vector3* worldVector, Vector3* normalVector);
```

## Parameters

- `screenX` (`float`) — A screen horizontal axis coordinate (0.0 - 1.0).
- `screenY` (`float`) — A screen vertical axis coordinate (0.0 - 1.0).
- `worldVector` (`Vector3*`) — The world coord vector pointer.
- `normalVector` (`Vector3*`) — The screen normal vector pointer.

## Returns

`void` — A Vector3 representing the world coordinates relative to the specified screen coordinates and a screen plane normal Vector3 (normalised).

## Description

*Source: Cfx.re native reference*

Converts a screen coordinate into its relative world coordinate.

## Usage

### Lua

```lua
local worldVector, normalVector = GetWorldCoordFromScreenCoord(screenX, screenY)

-- always available, by hash
local worldVector, normalVector = Citizen.InvokeNative(0xc81d0659, screenX, screenY, Citizen.PointerValueVector(), Citizen.PointerValueVector())
```

### JavaScript

```js
const [worldVector, normalVector] = GetWorldCoordFromScreenCoord(screenX, screenY);

// by hash
const [worldVector, normalVector] = Citizen.invokeNative('0xc81d0659', screenX + 0.0000001, screenY + 0.0000001, Citizen.pointerValueVector(), Citizen.pointerValueVector());
```

### C#

```csharp
var worldVector = new OutputArgument();
var normalVector = new OutputArgument();
Function.Call((Hash)0xc81d0659, screenX, screenY, worldVector, normalVector);
// worldVector.GetResult<Vector3>()
// normalVector.GetResult<Vector3>()
```

- 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.

## Examples

*Source: Cfx.re native reference*

```lua
CreateThread(function()
  while true do
    local screenX = GetDisabledControlNormal(0, 239)
    local screenY = GetDisabledControlNormal(0, 240)

    local world, normal = GetWorldCoordFromScreenCoord(screenX, screenY)

    local depth = 10

    local target = world + normal * depth

    DrawSphere(target.x, target.y, target.z, 0.5, 255, 0, 0, 0.5)

    Wait(0)
  end
end)
```

*Sources: Cfx.re native reference.*
