GetWorldCoordFromScreenCoord
Docslocal worldVector, normalVector = GetWorldCoordFromScreenCoord(screenX, screenY)Description
Converts a screen coordinate into its relative world coordinate.
Parameters
| Name | Type | Description |
|---|---|---|
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. |
Quick Snippet: Get CoordinatesworldVectornormalVector
worldVectornormalVectorAdd 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
voidThis native does not return a value.
Examples
Official
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)