Syncing a rolling ball?

Options
apper
apper
I am syncing a rolling ball.. it works really well for the master client, but it's super choppy for others.

Any idea how to make the ball smooth for master and other clients?

Here is some of the code that is used to sync the ball. I used the code for updating the player's locations and put it on the ball in a separate script:

void Update () { if (timer > 0) { timer--; } if (timer < 1) { started = true; } if (started == true) { if (photonView.isMine) { //Do nothing.. } else { transform.position = Vector3.Lerp (transform.position, realPosition, 0.10f); transform.rotation = Quaternion.Lerp (transform.rotation, realRotation, 0.10f); } } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){ if (started == true){ if(stream.isWriting) { stream.SendNext(transform.position); stream.SendNext(transform.rotation); } else{ realPosition = (Vector3)stream.ReceiveNext(); //transform.position = (Vector3)stream.ReceiveNext(); realRotation = (Quaternion)stream.ReceiveNext(); } } } }

Comments

  • PUN DemoSynchronization scene demoes 3 different ways of synchronized transforms smoothing.
    Try them and choose what is good for you.
    Current implementation looks like lerp type. Try interpolation type first (keep in mind that quality of interpolation depends on sendRate)
  • apper
    Options
    Thanks,

    I tried that but ran into the same problem.

    I've realized it is a physics problem. When the players hit the the ball, only the client who owns the ball can do it. The other players cannot hit the ball.

    Had anyone found a work around for this problem for photon? Do you have to apply force to the object via RPC so that the owner sees the force and sends the ball's new location to everyone else?

    Thanks
  • Tobias
    Options
    It is not very easy to accurately sync physical objects which can be affected by everyone (concurrently).
    PUN does not support this out of the box. One player controls a PhotonView or else, the results are going to be different on each client. To get around this limit, you can try to work with PhotonNetwork.RaiseEvent().
    Please search this forum for physics and related topics. Also, read Gaffer on Games for some insight what solutions are possible:
    http://gafferongames.com/networked-physics/introduction-to-networked-physics/