Keep some player instantiated objects in the room when leaving
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Keep some player instantiated objects in the room when leaving
Flod
2021-02-28 10:30:00
In my VR game i have an inventory where player can grab stuff out in their hand.
At first we instantiated the objects by the player - which felt good for the player in terms of visual feedback for the player.
Player share their stuff - and nobody is aware who pulled it out of his inventory.
When the player who originally grabbed the item out of his inventory leaves the game - the object is gone - even if another player is holding it right now.
So we changed to Instaniate as roomobject via rpc - now the visual feedback - in VR - is not good when players tend to have a slightly higher ping. as the object appears after the roundtrip RPC to masterclient and back to client
I read about the AutoCleanUp = false option - but I'm unsure about the downsides of it - ideally i would like to have a blacklist of - what to not "AutoCleanUp" when a player leaves.
Comments
https://forum.photonengine.com/discussion/17784/best-way-to-handle-prop-persistence-in-pun2#latest
I've been trying to get a straight answer for over a week. I wish you the best of luck.
What I gathered so far, is that PUN is not equipped to keep PhotonViews after the creator of them has left UNLESS you use CleanUpCacheOnLeave (previously known as AutoCleanUp). I've tried using this in my project with ... a small amount of success. When the player leaves, they now leave behind their entire player prefab. I tried using the OnOwnershipTransfered() to destroy the object after the player leaves.
Hopefully with two of us looking for a solution, this gains some traction.
Bump
Did you have a look into the AutoCleanup setting? It keeps all items by a player in the room but they can be destroyed by remaining players, so you can get rid of anything you don't want to show anymore.
Thanks again Tobias. I'm going to bite the bullet and implement this behavior.
Question. When the client that owns X object leaves, does OnOwnershipTransfered() trigger on all other clients in the room when CleanUpCacheOnLeave is set to false?
Also, CleanUpCacheOnLeave and AutoCleanup are the same, yes?
Back to top