- Documentation
- Server functions
- getPedTargetCollision
Function
getPedTargetCollision
Traces a ped's line of fire (from getPedTargetStart to getPedTargetEnd) and returns the first point where it hits a building, vehicle, ped or object. Returns false when nothing is in the way.
Syntax
float, float, float getPedTargetCollision(ped ped)Arguments
pedped- A player or an NPC.
Returns
The hit's x, y, z, or false.
Example
local hx, hy, hz = getPedTargetCollision(player)
if hx then createExplosion(hx, hy, hz, 12) end
See also
getPedTargetStartReturns the point where a ped's line of fire starts, i.e. the approximate muzzle position (same asgetPedWeaponMuzzlePosition). Together withgetPedTargetEndit defines the bullet path.getPedTargetEndReturns the end point of a ped's line of fire: the target set withsetPedAimTarget, or when none, a point 100 m ahead of the ped in the direction it faces.processLineOfSightFinds the first obstacle on the segment between two points and returns the hit details. On the client it asks the game (terrain, buildings, objects, cars, peds, collisions from .col files) and returns plenty of data: hit point, element, surface normal, material, lighting, body or vehicle part, and on request the map object model with its position. Each call waits about one game frame; while the world is still loading (loading screen) it returnsfalseat once. On the server it uses a simplified model (element spheres, no terrain or buildings).