Search Unity

Question Predicted Joints

Discussion in 'NetCode for ECS' started by rivFox, Aug 13, 2022.

  1. rivFox

    rivFox

    Joined:
    Nov 16, 2016
    Posts:
    6
    Hi,
    I'm trying to make a system where players can take an item. I'm using PhysicJoints for moving. The server makes a decision about what player can take an item (if both of them trying to do it in the same tick). For the interpolated player, everything looks good. But if the player is predicted, the connected item is delayed. It's because the item is interpolated and the joint wasn't replicated.

    The question is: how to make it works?
    1. I know that I should change the item to be predicted (there is an example, I know)
    2. Should I create a joint on the client side, right? Joints for the predicted client are supported?
    3. How to create a joint for the predicted client?
    3.1 Joint should be created only if the server decides that it should be created. Some delay is acceptable.

    My idea:
    On the server, I have information about the joint entity in the player's and the item's component.
    For one of their component, I can add a replicable component with the connected entity. The joint entity is local (is not a ghost). Next, create a joint if is not created and a connected entity exists. And destroy if exist and a connected entity doesn't.

    Or create a ghost joint entity.

    I hope you can help me understand how to do it best.
     
  2. rivFox

    rivFox

    Joined:
    Nov 16, 2016
    Posts:
    6
    Okey, the problem was that I forgot about PredictedPhysicsConfig. I decide to add joint components to my grabber and add an additional synced component with data. Then I set joint components by syncing the NetworkedJoint component.
     
    CMarastoni likes this.