Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Client is able to move through network objects. How to sync physics on client side? (see video)

Discussion in 'Netcode for GameObjects' started by maxkcy, Apr 11, 2023.

  1. maxkcy

    maxkcy

    Joined:
    Oct 11, 2021
    Posts:
    62

    Left is client, Right is server/host, I am controling client on the left, and watching through the host on the right. Physics are not synced perfectly. I have turned interpolation off, which made it better, but my player still goes through the crate. Is there a way the physics can be calculated on client side as well?

    How can I make physics more in sync on client side?
     
    Last edited: Apr 11, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,024
    I would say that your client‘s movement is client authoritative. This won‘t work well with physics because the physics simulation is server authoritative. Either make movement server authoritative, which will make client controls feel unresponsive/laggy. Or make each client‘s physics simulation locally by not using the NetworkRigidbody, instead relying on NetworkTransform to sync object transforms. This only works if you don‘t ever have two players interacting with each other physically, so to speak. Otherwise you have the same issue as now, except that client A can push the box into client B, and then B pushes it back. Actually I don‘t think the result will be acceptable either.

    Long story short: physics syncing isn‘t currently well supported by NGO. You may find better results with Fish-Net because it supports client-side physics simulation/prediction. Alternatively you could check how this is done and try to apply it to NGO.
     
    RikuTheFuffs and maxkcy like this.