Hey, I’ve been experimenting alot with the CalcView function recently. Particularly trying to make a over the shoulder view, I’ve been trying to get it right but i’m having problems with the crosshair glitching between places. I’ll post a video of this and the code below.

```
HeadBobAng = 0
HeadBobX = 0
HeadBobY = 0
function Camera(ply, origin, angles, fov)
if IsValid(ply) and ply:Alive() then
if HeadBobAng > 360 then
HeadBobAng = 0
end
if ply:KeyDown(IN_FORWARD) or ply:KeyDown(IN_BACK) or ply:KeyDown(IN_MOVERIGHT) or ply:KeyDown(IN_MOVELEFT) and ply:IsOnGround() then
local view = {}
view.origin = origin + angles:Forward()*-35 + angles:Up()*2 + angles:Right()*35
view.angles = angles
view.fov = fov
if( ply:GetVelocity():Length() > 150 ) then
HeadBobAng = HeadBobAng + 18 * FrameTime()
view.angles.pitch = view.angles.pitch + math.sin( HeadBobAng ) * .5
view.angles.yaw = view.angles.yaw + math.cos( HeadBobAng ) * .2
else
HeadBobAng = HeadBobAng + 14 * FrameTime()
view.angles.pitch = view.angles.pitch + math.sin( HeadBobAng ) * .5
view.angles.yaw = view.angles.yaw + math.cos( HeadBobAng ) * .3
end
return view
end
local view = {}
view.origin = origin + angles:Forward()*-35 + angles:Up()*2 + angles:Right()*35
view.angles = angles
view.fov = fov
view.angles.pitch = view.angles.pitch + math.sin( HeadBobAng )
view.angles.yaw = view.angles.yaw + math.cos( HeadBobAng )
return view
end
end
hook.Add("CalcView", "Camera", Camera)
hook.Add("ShouldDrawLocalPlayer", "DrawPlayerLocal", function(ply)
return true
end)
function CameraCrosshair()
local ply = LocalPlayer()
local trace = ply:GetEyeTrace()
local pos = trace.HitPos:ToScreen()
local gap = 5
local length = gap + 5
if !ply:IsBot() and ply:Alive() and IsValid(ply) and gap and length and trace.Hit then
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawLine(pos.x - length, pos.y, pos.x - gap, pos.y)
surface.DrawLine(pos.x + length, pos.y, pos.x + gap, pos.y)
surface.DrawLine(pos.x, pos.y - length, pos.x, pos.y - gap)
surface.DrawLine(pos.x, pos.y + length, pos.x, pos.y + gap)
end
end
hook.Add("HUDPaint", "CameraCrosshair", CameraCrosshair)
```