Skip to content

Commit

Permalink
fix(client/main): using camera
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm committed Oct 22, 2024
1 parent f649196 commit 9df2e06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ local function rotAnglesToVec(rot) -- input vector3
end

local function getVehicleInView(cam)
local coords = GetCamCoord(cam)
local forwardVector = coords + (rotAnglesToVec(GetCamRot(cam, 2)) * 400.0)
--DrawLine(coords, coords + (forward_vector * 100.0), 255, 0, 0, 255) -- debug line to show LOS of cam
local rayHandle = CastRayPointToPoint(coords.x, coords.y, coords.z, forwardVector.x, forwardVector.y, forwardVector.z, 10, cache.vehicle, 0)
local camCoords = GetCamCoord(cam)
local camRot = GetCamRot(cam, 2)
local forwardVector = rotAnglesToVec(camRot)
local targetCoords = camCoords + (forwardVector * 400.0)
local rayHandle = CastRayPointToPoint(camCoords.x, camCoords.y, camCoords.z, targetCoords.x, targetCoords.y, targetCoords.z, 10, cache.vehicle, 0)
local _, _, _, _, entityHit = GetRaycastResult(rayHandle)
return entityHit <= 0 and nil or IsEntityAVehicle(entityHit) and entityHit

return entityHit > 0 and IsEntityAVehicle(entityHit) and entityHit or nil
end

local function renderVehicleInfo(vehicle)
Expand Down
3 changes: 3 additions & 0 deletions config/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
policeHelicopter = 'polmav',
}

0 comments on commit 9df2e06

Please sign in to comment.