FPS - cinemachine camera jitter when using interpolation for rigidbodies

Hi, I’m creating an FPS game where the player can move on moving objects. These objects can move linear and rotate. The problem occurs when the player is on rotating objects. To make the camera rotate along with the player, I added a Cinemachine Pan Tilt component to it, and in FixedUpdate, I modify the values of panTilt.PanAxis.Value. Without interpolation, everything worked fine, but after enabling it, I get camera jitter. I added custom interpolation (screenshot) which reduced the problem to almost a minimum, but it still exist, which causes an uncomfortable feeling.

I’m wondering if there’s a better way to handle camera rotation or if the interpolation can be written more effectively.

Additional information

  • everything related to physics is moved by rigidbody, only camera rotation is changed by script as written below
  • cinemachine brain update method: “Late Update”


Custom interpolation:

Enabling interpolation on the RB makes it so that its transform gets set with appropriately interpolated values before Update is called. Because that is happening, observers of that object (such as Cinemachine and your panTilt angle-setting code) should treat the object just like any non-physics object being animated with update.

In other words, you should be computing angleDiff during Update - not FixedUpdate - and applying it directly with no interpolation.

That said, it’s not clear why you need this code at all. PanTilt has a field that allows you to control what object the PanTilt values are in relation to. Why not just set that to your player?

Thanks for the quick response. Somehow, I didn’t notice that I could control what the Pan Tilt values are relative to. After changing it to tracking target, there was still an issue with interpolation. It’s possible that I overcomplicated something, but once I set the Tracking Target’s rotation in Update instead of FixedUpdate, I got the desired effect.

1 Like