Skip to content

Instantly share code, notes, and snippets.

@DemmyDemon
Created January 28, 2018 15:33
Show Gist options
  • Save DemmyDemon/a3cf002caa892e8a11990291a94c4a25 to your computer and use it in GitHub Desktop.
Save DemmyDemon/a3cf002caa892e8a11990291a94c4a25 to your computer and use it in GitHub Desktop.
Slightly wrong vector math. WTF.
function pGetAimedLocation(range)
range = range or 100
local playerPed = PlayerPedId()
local location = GetEntityCoords(playerPed,true)
local rot = GetGameplayCamRot(0)
local pitch = math.rad(rot.x)
local roll = rot.y -- We can ignore this one, as it has no bearing on the final location
local yaw = math.rad(rot.z)
local x2 = range * math.sin(yaw)
local y2 = range * math.cos(yaw) * math.sin(pitch)
--local z2 = range * math.cos(pitch) * math.cos(yaw)
local z2 = 0.0
hudText(rot.x..','..rot.z,0.8,0.1,7,0.2)
hudText('X1 = '..location.x,0.8,0.20,7,0.2)
hudText('X2 = '..x2,0.8,0.21,7,0.2)
hudText('Y1 = '..location.y,0.8,0.22,7,0.2)
hudText('Y2 = '..y2,0.8,0.23,7,0.2)
return vector3(location.x + x2, location.y + y2, location.z + z2)
--StartShapeTestRay(location.x,location.y,location.z,)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment