M MY Multiplayer: Wiki
Lado
Tipo

processLineOfSight

Cliente

Lanza un rayo entre dos puntos y devuelve lo primero que toca.

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])

Parámetros

NombreTipoDescripción
startX, startY, startZfloatDonde empieza el rayo. También acepta un vec3.
endX, endY, endZfloatDonde termina el rayo. También acepta un vec3.
checkBuildingsboolSi cuentan los edificios.por defecto true
checkVehiclesboolSi cuentan los vehículos.por defecto true
checkPedsboolSi cuentan los peds.por defecto true
checkObjectsboolSi cuentan los objetos.por defecto true

Retorno

false si no tocó nada. Si tocó algo, true, el punto tocado, la normal de la superficie en ese punto y el elemento tocado (nil cuando no es un elemento, como un edificio del mapa).

Ejemplo

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

Ver también