GetLinePlaneIntersection
Docslocal retval, intersectionParameter = GetLinePlaneIntersection(x1, y1, z1, x2, y2, z2, planeX, planeY, planeZ, planeNormalX, planeNormalY, planeNormalZ)Description
Introduced in build 323
Determines whether a line segment intersects a plane and, if so, returns the parameter value at which this intersection occurs.
Parameters
| Name | Type | Description |
|---|---|---|
x1 | float | The X-coordinate of the first point of the line segment. |
y1 | float | The Y-coordinate of the first point of the line segment. |
z1 | float | The Z-coordinate of the first point of the line segment. Together, `x1`, `y1`, and `z1` define the starting point of the line segment. |
x2 | float | The X-coordinate of the second point of the line segment. |
y2 | float | The Y-coordinate of the second point of the line segment. |
z2 | float | The Z-coordinate of the second point of the line segment. Together, `x2`, `y2`, and `z2` define the ending point of the line segment. |
planeX | float | The X-coordinate of a point on the plane. This, along with `planeY` and `planeZ`, specifies a point that lies on the plane's surface. |
planeY | float | The Y-coordinate of a point on the plane. |
planeZ | float | The Z-coordinate of a point on the plane. |
planeNormalX | float | The X-component of the plane's normal vector. The normal vector is perpendicular to the plane's surface and defines its orientation. |
planeNormalY | float | The Y-component of the plane's normal vector. |
planeNormalZ | float | The Z-component of the plane's normal vector. Together, `planeNormalX`, `planeNormalY`, and `planeNormalZ` fully describe the plane's orientation in 3D space. |
intersectionParameter | float* | A pointer to a float. This parameter is used to return the value of `t` at which the line segment intersects the plane. The value of `t` is a scalar multiplier that can be used to calculate the exact intersection point on the line segment. If the line does not intersect the plane, the value of `t` is not meaningful. |
Quick Snippet: Get Coordinatesx1y1z1x2
x1y1z1x2Add 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)Vehicle Models

adder
alpha
blade
ardent
asea
cogcabrio
baller
blistaReturns
BOOLReturns TRUE (1) or FALSE (0).
Examples
Official
-- Define the line segment with start and end points
local startX, startY, startZ = 100.0, -200.0, 50.0
local endX, endY, endZ = 200.0, -100.0, 50.0
-- Define the plane with a point on the plane and the normal vector
local planeX, planeY, planeZ = 150.0, -150.0, 50.0
local normalX, normalY, normalZ = 0.0, 0.0, 1.0
-- Call the native
local success, intersectionParameter = GetLinePlaneIntersection(startX, startY, startZ, endX, endY, endZ, planeX, planeY, planeZ, normalX, normalY, normalZ, intersectionParameter)
if success then
-- Calculate the intersection point using intersectionParameter
local intersectX = startX + (endX - startX) * intersectionParameter
local intersectY = startY + (endY - startY) * intersectionParameter
local intersectZ = startZ + (endZ - startZ) * intersectionParameter
print("Intersection point at: (" .. intersectX .. ", " .. intersectY .. ", " .. intersectZ .. ")")
else
print("No intersection found.")
end