OnApplicationPause + control the "paused" player

Keplerians

New member
Hi!

We are being into some troubles when a player pause the game (open other app for seconds, got a call, etc), we now managed to be able to kill that player normally (applying the damage + killing it correctly). But we will have some more situations to control, and we would like to get different aproaches regarding this matter.

For example, if you make your character jump and inmediately switch to other app (in android) while your character is in the air, the other players would see him frozen in the air. We now enable the CharacterLocomotion script while the player is paused (for the other players), then the character falls correctly, but when the player comes back to the game after few seconds, the character falls again, since the character continues the jump action... (and sometimes falling down throught the floor)

How would you do it?

We tried also to transfer the photonview ownership to the master client (and control the player as a bot), but since I believe opsive is not ready for that, there are plenty of errors...

So we will keep doing some tests about this, but we would like to have your suggestions :)

Thank you in advance.
 

Justin

Administrator
Staff member
Generally you can't pause a multiplayer game so the simulation has to keep running. When the app is switched you could disconnect the player and then have them rejoin if the app is resumed.
 

Keplerians

New member
Since its a game where 4 players fight in a closed room, if you are attacking a player, and he minimize the app (the game for this player is paused, and wont receive/send anything meanwhile), you have to be able to kill him anyway. For example is what happens in fortnite, or other mobile multiplayer games, you can kill those "afk" players. Do you know any approach to do it correctly?

Thanks.
 

Justin

Administrator
Staff member
You could switch the owner of that player to the master client. I haven't tried this but you can perform the switch by following this page. The SpawnManagerBase looks for when the player leaves and does the appropriate transfer if they are the master client, but does not handle transferring a non-master client over to the master client. I can add this to my feature request list.
 

Keplerians

New member
Thanks for the answer.

And for having success when switching the ownership of that player to the master client, which changes do you think are needed? Because that is what we tried doing, but for example there are plenty of references to the "Look source" but is null since this character is managed by other player, etc.

We were doing override to some of the Pun network monitors like transform monitor, etc so we can manage the situation when the player is out, but some scripts are not virtual, and we are afraid to do changes in the original scripts of the plugin... We try to override all of them so we can update the plugin in future updates without problems...
 

Justin

Administrator
Staff member
It's extremely tough to say without getting into it but I would start by going through the OnPlayerLeftRoom method. This will give an idea for the cleanup that needs to be done when switching owners.
 
Top