Exiting a UNET lobby causes future ClientRPC calls to be ignored.
Hello everyone.
I've been using UNET for the project I'm working on, and I did most of the my set up by referencing the TANKS multiplayer lobby example. It all works very well, except for one scenario.
If I create a lobby, leave, and then create a new lobby, it all seems to be fine, up until the point where my game manager makes some ClientRPC calls. For some reason, the RPC calls that control my game loop don't get called. They work fine whenever I just enter the lobby once, and then go into the gameplay, but if at one point I leave a lobby and enter a new one, they don't work.
The problem is present in both local hosting and matchmaking.
I did a test where I removed the [ClientRpc] property from my GameLoop methods, and it works well again, except that it won't be synced up properly on all clients.
Does anyone have any ideas on how to approach this problem?
You're help would be greatly appreciated. Thanks.
Answer by Alberto-Mastretta · Apr 04, 2016 at 07:35 PM
I solved it. My race manager was grabbing the first lobby player as it's listener, and then when the lobby player got destroyed, the connection would get lost. Whenever I created a new player, the Race Manager wouldn't grab it as it's new listener automatically. I solved by instead just moving my race manager to the play scene instead of having the object as a non destroy that lived across scenes.