Reconnect Ownership Problem

Options

Hello,

I am designing a Tower Defense multiplayer game with Photon. Placing Towers have PhotonViews on them and using OnPhotonSerializeView to store tower parameters and values synced with master and clients.

When a tower owner client disconnects, I am using PhotonNetwork.RejoinRoom, everything works perfect about reconnection. But tower is going back to owner automatically, even i use Takeover or Request on Ownership Transfer. So i lose all parameters and values on Tower. I am trying to give ownership manually to owner when is active, so i can store values first then i can give ownership. How can i do that?

And when i am using join room with room name, it is saying Game Full error, even i successfully disconnect from server. Thought join room can do all stuff manually, but i am getting that Game Full Error.

A bit stuck on this, can you help please?

Thanks.

Answers

  • Tobias
    Options

    So i lose all parameters and values on Tower. I am trying to give ownership manually to owner when is active, so i can store values first then i can give ownership. How can i do that?

    Returning the ownership is automated but you are right: It can cause this loss of state. I fear, that is not possible without modifying PUN somewhat. Did you look into this already or is it still open? Maybe I can have a look at details on Monday. It's more than a simple bool value option.

    Join will let you join the room as another user. This won't fit, unless the old connection is gone and PlayerTTL passed. It is better to use ReconnectAndRejoin anyways.


    When I read you use OnPhotonSerializeView to pass values for towers in a tower defense, I wonder if Custom Room Properties or Custom Player Properties wouldn't be better suited. You change the towers less frequently than 10x per second, so properties might be fine. And they don't have ownership as such.

  • Hello,

    Yes it is still open, when disconnected and object returned to master, i switched ownership transfer to Fixed for avoiding losts of state. Then i couldnt take back the ownership to real owner after reconnection. Tried some possible tricks but couldnt reach to success :)

    I will try ReconnectAndRejoin, but in logic i am reconnecting again and using Rejoin seems same to me :)

    I have 7 different tower types, ranges, damages, values etc.. are different. So i guess custom player properties wont fit for that situation. Every tower have unique stats and values.

    Thanks for your help again.

  • Hello again,

    I just solved that issue with that code at update, it is working fine for now :)

    I will let you know, if something went wrong. Storing creatorActor as unique userId, and added that value on OnPhotonSerializeView. After reconnection checking that value with authenticated userId, and transferring Ownership back.

    I know this is not a nice solution, but works :)


    if (photonView.IsMine && turret != null && string.IsNullOrEmpty(creatorActor) && photonView.IsOwnerActive)

          {       

            creatorActor = PhotonNetwork.AuthValues.UserId;

            turret.GetComponent<Turret>().creatorActor = creatorActor;

            Debug.Log("Tower initial build creatorActor: " + creatorActor);

          }

           

          if(photonView.IsMine && !photonView.IsOwnerActive && photonView.OwnerActorNr != PhotonNetwork.LocalPlayer.ActorNumber)

          {

            Debug.Log("Owner disconnected, new master releasing owner actor value");

            photonView.OwnerActorNr = PhotonNetwork.LocalPlayer.ActorNumber;     

          }


          if (!photonView.IsMine && creatorActor == PhotonNetwork.AuthValues.UserId)

          {

            Debug.Log("After disconnection take ownership back");

            photonView.RequestOwnership();      

          }


    Thanks.

  • Tobias
    Options

    Thanks for the update. Glad you found a solution.