[PUN2] CleanupCacheOnLeave=FALSE doesn't work, gameobject are always destroy

Options

Hi,

We want to allow those who experience a disconnection to be able to return to the game.

So we use the PlayerTtl, but this is very confusing because there are 2 LeaveEvent, a first when disconnecting and a second when the TTL is consumed

But the problem is as soon as the player is disconnected, all the objects that belong to him are destroyed locally, at the first TTL (and correctly destroy on second TTL in other client)

We don't want the prefab instances to be destroyed, but it looks like the option CleanupCacheOnLeave doesn't work

Thank you for your help

RoomOptions roomOptions = new RoomOptions()
			{
				MaxPlayers = (byte)lastMaxPlayer,
				CustomRoomPropertiesForLobby = new string[] { "C0", "C1", "C5" },
				CustomRoomProperties = props,
				EmptyRoomTtl = 0,
				PlayerTtl = 30000,
				PublishUserId = true,
				CleanupCacheOnLeave = false
			};		
			string[] friendsStr = null;
			if (party.friends.Count > 0)
			{
				friendsStr = party.friendNames.ToArray();
			}
			PhotonNetwork.CreateRoom(null, roomOptions, new TypedLobby("Noara_Conspiracy", LobbyType.SqlLobby), friendsStr);

Comments

  • mastergame
    edited November 2021
    Options

    I found out why, I think it's a photon bug.

    In the PhotonHandler class the player's objects are always destroyed if the player leaves the room, without testing his status inactive

    This class adds functions that are done by default, such as for example the reassignment of photonviews to the master of a player who leaves the room and again without testing the status of the player

    Or maybe, as photon raises 2 leaveroom events, this may be the problem, because I find it disconcerting that we are notified of a leaveRoom the first time, then a second time after the time of PlayerTTL has elapsed

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2021
    Options

    Hi @mastergame,

    Thank you for choosing Photon!

    I think for the local client a total room clean up will happen (all objects destroyed) as soon as the local player left the room (in all cases) by design as soon as the room is left and I don't think we're going to change this.

    Feel free to change this and add a check (CurrentRoom.AutoCleanUp) if you want to have a different behaviour.

    @Tobias can confirm or rectify if the information is incorrect.

    Same thing for remote players after PlayerTTL expiration. In this case I would simply increase PlayerTTL or make it infinite (-1 or int.MaxValue).

  • Thank you for your answer, it is always annoying to modify a class of a third party library which means that these developments will be overwritten during an update.

    It would be of little interest to have the possibility of assigning callbacks if the default operation of the PhotonHandler class is not suitable.

    I give the example, our game is a 2vs2, if a player leaves the game, we want his teammate to take control of his units and not the master, but this is hard-coded in the PhotonHandler class


    Here the link on early access of game on steam

    https://store.steampowered.com/app/1101030/Noara_The_Conspiracy/