Physics interpolation problems with gun

Godot Version

4.4

Question

I’m using physics interpolation for my project so I don’t get the annoying jitter when moving the player and camera, but the issue is that when I enable it the gun does this weird jitter thing and the only solution is to disable physics interpolation

You can disable physics interpolation per node and branch by changing its Node.physics_interpolation_mode property.

Tried it before the jitter happenes while moving the camera, after disabling it even movement without camera movement causes jitter

Hey if you still need help, I ran into this problem and found the solution.

What I found worked was resetting the gun’s global_transform with the interpolated global transform of the camera (or whatever node you are applying your mouse movements to). I then reapply it’s local position offset with .translated_local(). This is done is _process()

gun.global_transform = camera_pivot.get_global_transform_interpolated().translated_local(GUN_OFFSET)

I think the issue has something to do with the clashing of interpolated character movements which ultimately affects the weapon’s global_transform, and framerate-dependent camera movements also ultimately changing the gun’s global_transform. It seems like this code overrides the interpolated position. I’m not 100% sure how/why it works though lol.

I adjust my camera’s rotation in _unhandled_input() so if you doing it in _process() this probably comes after the camera rotation updates.