# processLineOfSight (Client)

> Casts a ray between two points and returns the first thing it hits.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: World and weather
- **URL**: https://wiki.mymp.gg/en/processLineOfSight

## Syntax

```lua
bool, vec3, vec3, element|nil processLineOfSight(float startX, startY, startZ, float endX, endY, endZ [, bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true, bool checkObjects = true])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `startX, startY, startZ` | `float` | Where the ray starts. A `vec3` also works. |
| `endX, endY, endZ` | `float` | Where the ray ends. A `vec3` also works. |
| `checkBuildings` | `bool` | Whether buildings count. *(default: `true`)* |
| `checkVehicles` | `bool` | Whether vehicles count. *(default: `true`)* |
| `checkPeds` | `bool` | Whether peds count. *(default: `true`)* |
| `checkObjects` | `bool` | Whether objects count. *(default: `true`)* |

## Returns

`false` if nothing was hit. Otherwise `true`, the hit point, the surface normal there and the element hit (`nil` when it is not an element, such as a map building).

## Example

```lua
local function firstHit(from, to)
    local hit, position, normal, element = processLineOfSight(from, to, true, true, false, true)
    if hit and element then
        outputDebugString("Hit a " .. getElementType(element))
    end
    return hit and position
end
```

## See also

- [isLineOfSightClear (Client)](https://wiki.mymp.gg/en/isLineOfSightClear.md): Tells whether nothing blocks the segment between two points. Only buildings and objects block it, not vehicles or peds.
- [getGroundPosition (Client)](https://wiki.mymp.gg/en/getGroundPosition.md): Finds the ground right below a point, up to 1000 m down. Only buildings and objects count.
- [getWorldFromScreenPosition (Client)](https://wiki.mymp.gg/en/getWorldFromScreenPosition.md): Turns a screen point, at a depth, into a world point, with the current frame's camera.
