Unity rigidbody synchronize (ownership)

Hi, I’m new to Photon network API and the Unity network API. I’m trying to develop a game similar to Air Soccer Fever (https://play.google.com/store/apps/deta ... ever&hl=es).
I’m currently synchronizing the balls by using a PhotonView per Ball, each one with the owner has the machine that run the team. The balls are rigidbodies and a synchronize only the position making a Lerp so it is more or less smooth (I don’t know if this is the usual way when working with RigidBodies in Photon/Unity).

My problem comes when ball from say team A hits a balls from team B, because the balls from team B have as owner his player and the writer of the position is that client then even when tha ball from team A moves the ball from team B it will automatically reposition because the client that “writes” the position is the client from team B. I don’t know if it is clear but that is the problem.
The solution that I think would be the easiest (if possible implementing) will be changing the ownership of the PhotonView so that when it is the turn of team A his client controls (owns) all the balls, and in the turn of team B then its own all the balls. I don’t even know if this solution would be possible or if another think should be do.
Any advice in this?


  • Yeah this is a tough one.

    I think you can indeed gain some better results by switching ownership. You could do this by -not- using PhotonNetwork.Instantiate for the ball, but instead use manual allocation. Manually spawn the ball on every client and have every client allocate and share a viewID that will be reserved for ball ownership (PhotonNetwork.AllocateViewID()).

    Whenever the ball ownership changes, have someone send a RPC on a scene photonview (that never changes ownership). When players get this message, have them all locally change the ID to the new owner.

    That should be it..