Hi, I am working on a gamemode where the player runs into a physical football. When this happens the camera starts to jutter quickly due to the player colliding with the ball.
This is the code I have: (I used math.Approach to try to smoothen the stutter caused by the collisions with the ball)
function GM:CalcView(ply, pos, angles, fov)
if cameraMode then return end
local trace = {}
local view = {}
local distance = 110
trace.start = pos
trace.endpos = pos - (angles:Forward() * distance)
trace.filter = LocalPlayer()
local trace = util.TraceLine(trace)
local current = current or trace.HitPos:Distance( pos ) - 10
if( trace.HitPos:Distance( pos ) < distance - 1 ) then
current = math.Approach(current, 159, 1)
end
current = math.Approach(current, distance, (distance - distance) * FrameTime() * 10)
print(current)
distance = current
view.origin = pos - (angles:Forward() * distance) + (angles:Right() * 40)
view.angles = angles
local speed = ply:GetVelocity():Length()
view.fov = fov + (speed/28)
return view
end
But seems like I fucked up somwhere and it acts exactly the same. Does anyone know where I have gone wrong?
Cheers.
Sorry, you need to Log In to post a reply to this thread.