So basically I have a script that loads my level and spawns my player. The level is procedurally loaded. So the first person who connects becomes the master client. If they are the master client they trigger the level to render when they connect. However if I open another instance of this game and connect, my player will just spawn in before the rendering is done. How can I make it so that the players spawn when 2 of them are connected??
Here is what I have tried:
Setting an int to 0 or 1 while the level is rendering by calling an RPC like so:
with the SetBool Function looking like this:
Then I know that I need to check if this number equals 1 when players connect. But the issue is if a player connects and the level is still rendering, it says the integer is still zero. I cannot check again if that integer equals 1 because the function OnJoinedRoom() is only called when you Join. I have tried the Update() function and had no luck either because it is called every frame.
So what I think I need it someway to keep checking every 1 or 2 seconds if the integer is set to 1… But I’m not sure how to go about that in networking. I’m not even sure if the other players client even accepts the current integer change, meaning if client 1 says it equals 1, how do I know that client’s is getting the same thing, what if client 2 is still getting 0…
To many things going on…
Sometimes I think it may be easier to write code for a lobby system, but I feel like that it is going to add a lot more headaches and I’m not 100% sure how.
Thanks for reading I hope this makes sense.