how to re-use ViewID of a disconnected player ?

Hello everyone,

I have a general question in topic of ViewIDs,
So if i created a room my default ViewID would be 1001.
When someone join the room, his ViewID is 2001, the next will be 3001 and so on...
My problem here is that if the person with the ViewID disconnect, so the room currently only have the owner (1001) if another one connect to the room (even the old 2001) his ViewID will be set automatically to 3001 instead of 2001
This gif explained better :
P2 disconnect, and he connect again, he got assigned as P3 instead of P2
viewID.gif

Our game only allow 4 player per room so we can easily find our way around this, i just want to know if there is an automatic way to make "2001" available if its owner is disconnected.

PS :
i tried using UnAllocateViewID but i still get the same result.

Thank you

Comments

  • Okay so i fixed this by setting the ID based on the number of player inside the room and then write/stream it to have the correct result. I still want some clarification around UnAllocateViewID though, i would appreciate it if anyone could explain it better. Thanks
  • If owner is disconnected but object still in scene (e.g. because of PhotonNetwork.autoCleanUpPlayerObjects = false), new player can take ownership of that object with RequestOwnership() call on object's PhotonView. The viewId remains the same and reused in some sense in that case.
    But as soon as player left and object destroyed, no way to reuse viewId since every new viewId built up from player id (increments each time new player joins) and some local index.