Created
July 22, 2019 09:54
-
-
Save ExtReMLapin/2420074d190a33edf9c19fab36b60150 to your computer and use it in GitHub Desktop.
gmod but with a realistic view angle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- reference and calcs : https://i.imgur.com/G81PMSd.jpg | |
-- drop me in autorun/client/ | |
local intensity = 1 | |
local function cmtounit(cm) | |
return math.Remap(cm, 0, 173.736, 0, 96) | |
end | |
local cmDistanceUpPivot = 21.384 * intensity -- (cm) | |
local cmDistanceForwardPivot = 14.87 * intensity -- (cm) | |
local sourceUnitsDistanceUpPivot = cmtounit(cmDistanceUpPivot) -- (source units) | |
local sourceUnitsDistanceForwardPivot = cmtounit(cmDistanceForwardPivot) -- (source units) | |
local fixVector = Vector(0, 0, sourceUnitsDistanceUpPivot) | |
local UCalcView = function(ply, pos, angles, fov) | |
local view = {} | |
view.origin = pos + (angles:Forward() * sourceUnitsDistanceForwardPivot) + (angles:Up() * sourceUnitsDistanceUpPivot) - fixVector | |
view.angles = angles | |
view.fov = fov | |
view.drawviewer = false | |
return view | |
end | |
hook.Add("CalcView", "RealisticViewSystem", UCalcView) | |
hook.Add("CalcVehicleView", "RealisticViewSystem", UCalcView) | |
hook.Add("CalcViewModelView", "RealisticViewSystem", function(wep, vm, oldPos, oldAng, pos, ang) | |
pos = pos + (ang:Forward() * sourceUnitsDistanceForwardPivot) + (ang:Up() * sourceUnitsDistanceUpPivot) - fixVector | |
return pos, ang | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment