Modify Shoot Pos

I’ve been working on a leaning addon for a couple of hours and ran into an issue when leaning the players shoot pos does not follow the view.



hook.Add("CalcView", "DaxisLeaning", function( ply, pos, angles, fov )
      if leanright then
            anglerp = Lerp(5 * FrameTime(), anglerp, 13.25)
            multlerp = Lerp(3.25 * FrameTime(), multlerp, 20)
            angles.r = anglerp
            newangles = Angle( angles.p, angles.y, angles.r )
            neworigin = pos + ( ply:GetRight() * multlerp )
            print( ply:GetViewOffset() )
            if not done then
                  done = true
            end
      end
      if leanleft then
            anglerp = Lerp(5 * FrameTime(), anglerp, -13.25)
            multlerp = Lerp(3.25 * FrameTime(), multlerp, -20)
            angles.r = anglerp
            newangles = Angle( angles.p, angles.y, angles.r )
            neworigin = pos + ( ply:GetRight() * multlerp )
            if not done2 then
                  done2 = true
            end
      end
      if not leanleft and not leanright then
            anglerp = Lerp(4.25 * FrameTime(), anglerp, 0)
            angles.r = anglerp
            multlerp = Lerp(3.25 * FrameTime(), multlerp, 0)
            newangles = Angle( angles.p, angles.y, angles.r )
            neworigin = pos + ( ply:GetRight() * multlerp )
            if done then
                  done = false
            end
            anglerp = Lerp(4.25 * FrameTime(), anglerp, 0)
            angles.r = anglerp
            if done2 then
                  done2 = false
            end
      end


      return { origin = neworigin, angles = newangles }
end)


hook.Add("CalcViewModelView", "ViewModelTilt",function( wep, vm, oldPos, oldAng, pos, ang )
      if leanright then
            anglerp2 = Lerp(2.5 * FrameTime(), anglerp2, 4)
            ang.r = anglerp2
            vectorview = pos + ( LocalPlayer():GetRight() * multlerp )
            pos.x = vectorview.x
            pos.y = vectorview.y
            pos.z = vectorview.z
      end
      if leanleft then
            anglerp2 = Lerp(2.5 * FrameTime(), anglerp2, -4)
            ang.r = anglerp2
            vectorview = pos + ( LocalPlayer():GetRight() * multlerp )
            pos.x = vectorview.x
            pos.y = vectorview.y
            pos.z = vectorview.z
      end
      if not leanright and not leanleft then
            anglerp2 = Lerp(3 * FrameTime(), anglerp2, 0)
            ang.r = anglerp2
            vectorview = pos + ( LocalPlayer():GetRight() * multlerp )
            pos.x = vectorview.x
            pos.y = vectorview.y
            pos.z = vectorview.z
      end
end)


Any help would be appreciated, and thank you for your time.

I would recommend you to use EntityBulletFire hook and then modify it source

If you do this don’t do it clientside. The bullets will look like they’re being shot where you want them but on the server they’ll be in the wrong place.

Thank you, didn’t even know that existed.