How to sync the camera?

I’m working on a quick FPS tech demo to test out client-server with UNet. I’ve run into a problem; namely, how to keep camera movement smooth. I’m using a rigid body character with my own update code. Characters are just capsules. The gun, in classic tradition, follows the camera (is a child transform of the camera).

  1. If I just adjust the camera’s pitch and let the NetworkTransform on the character interpolate, then it’s very swoopy.
  2. If I don’t interpolate, it’s very laggy.
  3. If I try to update the camera itself from the client (using an authoritive client NetworkIdentity), it desyncs from the rigid body rotation.

Since this is entirely my own code, here, have the entire codebase. It’s very short. (DestroyTimer is used on the bullet sparks).

2153815–142206–DestroyTimer.cs (476 Bytes)
2153815–142207–DisableIfLocal.cs (566 Bytes)
2153815–142208–DisableIfNotLocal.cs (570 Bytes)
2153815–142209–MyCharacterController.cs (5.95 KB)

1 Like

is the camera a child of the capsule?

Yes, the camera is a direct child of the capsule.