HasEntityClearLosToEntity
Docslocal retval = HasEntityClearLosToEntity(entity1, entity2, flags)Description
Checks if entity1 has a clear line of sight to entity2. So a simple raycast which if it collides with any of the given colliderTypes returns false.
The direction of the check matters with for example bushes, so checking from inside to outside a bush with traceType 256 returns true, but the other way around returns false.
Parameters
| Name | Type | Description |
|---|---|---|
entity1 | Entity | Entity to start from |
entity2 | Entity | Entity to check to |
flags | int | A bit mask with bits 1, 2, 4, etc, relating to collider types (see: [START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE](#\_0x377906D8A31E5586)). 17 is most common in GTA scripts. |
Quick Snippet: Get Entityentity1entity2
entity1entity2Use this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
BOOLReturns TRUE (1) or FALSE (0).