Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------
- -- This script overrides garry's vehicle thirdperson view function
- -- so that props do not obstruct the camera
- --
- -- Place in lua/autorun/
- -- fuck the police
- ---------------------------------------------------------------------
- --if SERVER then AddCSLuaFile() return end
- timer.Simple( 1, function()
- function GAMEMODE:CalcVehicleView( Vehicle, ply, view )
- if Vehicle.GetThirdPersonMode == nil then return end
- -- If we're not in third person mode - then get outa here stalker
- if not Vehicle:GetThirdPersonMode() then return view end
- local mn, mx = Vehicle:GetRenderBounds()
- local radius = (mn - mx):Length()
- local radius = radius + radius * Vehicle:GetCameraDistance()
- -- Trace back from the original eye position, so we don't clip through walls/objects
- local TargetOrigin = view.origin + ( view.angles:Forward() * -radius )
- local WallOffset = 4
- local tr = util.TraceHull( {
- start = view.origin,
- endpos = TargetOrigin,
- filter = Vehicle,
- mins = Vector( -WallOffset, -WallOffset, -WallOffset ),
- maxs = Vector( WallOffset, WallOffset, WallOffset ),
- mask = MASK_NPCWORLDSTATIC
- } )
- view.origin = tr.HitPos
- view.drawviewer = true
- -- If the trace hit something, put the camera there.
- if tr.Hit and not tr.StartSolid then
- view.origin = view.origin + tr.HitNormal * WallOffset
- end
- return view
- end
- end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement