Moving flashlight with camera when using CalcView

I’m using a CalcView hook to move my camera including the view model.

Now that part works well, except the flashlight doesn’t move with the camera.
So my question is: how do I move the flashlight?

I can probably use any hook that can change the camera given a new origin+angles, whatever works.

The whole thing is rather complex so I boiled it down to this example:
[lua]
hook.Add(“CalcView”, “blergh”, function(ply, origin, angles, fov)
origin = origin+angles:Right()*100
return {
origin = origin,
angles = angles,
vm_origin = origin,
vm_angles = angles,
fov = fov,
}
end)
[/lua]

EDIT: I realized it wasn’t possible to move the physgun beam so it doesnt go all freaky, so I decided to switch to RenderScene and render twice there:

  • once for the backgound
  • once for the foreground, with reduced z plane
    The plan for the foreground is to only render models, which is another thing I need to figure out :slight_smile:
    Failing that, I’ll just move them to a place with no textured brushes nearby or something…

The result is obviously:

  • 2 viewmodels (i know how to get rid of the additional one)
  • 2 physgun halo sprites (I’m not quite sure how to get rid of the 2nd sprite)
  • 2 flashlights (I have absolutely no idea how to move them)

[SUP]Also posted on wiremod.com[/SUP]