Search Unity

How to sync the camera?

Discussion in 'Multiplayer' started by SeriousBusinessFace, Jun 11, 2015.

  1. SeriousBusinessFace

    SeriousBusinessFace

    Joined:
    May 10, 2014
    Posts:
    127
    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).
     

    Attached Files:

    erebel55 likes this.
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    is the camera a child of the capsule?
     
  3. SeriousBusinessFace

    SeriousBusinessFace

    Joined:
    May 10, 2014
    Posts:
    127
    Yes, the camera is a direct child of the capsule.