GameObject Instantiated before Scene Completes Loading when Joining Room

Options
I am just getting started using PUN and OnSite server with Unity. Overall it's going well. I'm able to create a lobby and use it for clients to join a room. I've set it up so that a UMA character instantiates as soon as you enter the room. The UMA's are networked so any proxies also spawn. The problem I've encountered is that the second player to enter a room receives an error that the UMA libraries aren't available. The issue is that the first UMA character to spawn is the networked (proxy) character. When this happens it appears that the scene hasn't fully loaded (the new room is in a new scene) and the GameObject with the UMA libraries (context, overlay, slot...) haven't loaded. The second UMA character to load, the local player, loads just fine. On the first client, that created the room, both UMA's are showing because the scene has already been loaded.

My first thought was to use a coroutine to delay the spawn of the UMA until the needed library GameObjects could be found. The coroutines get initiated on two separate GameObjects but only the second one completes. The first one seems to get overwritten by the first. Didn't think that was supposed to happen, especially on separate scripts on two different game objects, but it did. I've tried the OnJoinedRoom callback but that was called even before the spawn.

I have a couple of question perhaps someone can help me with. I've used UMA with a couple of different networking systems but, frankly, I'm at a loss here.

1. It isn't clear how the spawn of the proxy character is happening in code. Can someone point me to where I should look for this?

2. Does anyone know of another callback that might be better than OnJoinedRoom? I looked at the Pun Callback list but didn't see anything.

Any help would be greatly appreciated!

Best Answer

Answers