The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

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.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Sync loading for every players before spawn in Scene

2018-09-05 13:06:21

Hello everyone,

I am trying to make synchronous loading so that after number of players in room reach 6 players then the game will go to loading scene before spawning players at same time in arena then start the timer. I wonder how to do that in PUN?

Thank you for your help


[Deleted User]
2018-09-06 08:33:36

Hi @ActiveDream,

you can use the void OnPhotonPlayerConnected(PhotonPlayer otherPlayer) callback. It gets called whenever a new player joined the room. If you are the MasterClient, you can check in this callback and do something, if the desired amount of players is in the room.

2018-09-06 10:09:50

Hi Christian_Simon, thank you for your reply. I did that but the problem now seems that master client and the rest of the players did not enter the arena at the same time thus the timer in each players is slightly different. How to make every player enter arena at same time?

[Deleted User]
2018-09-06 10:58:08

If the desired number of players is in the room, the MasterClient can load a new scene. If you have enabled PhotonNetwork.automaticallySyncScene, all clients will load that scene. However they won't start and finish loading the level at the exact same time - there is nothing you can do about that. But you can coordinate when the timer starts running in order to have it synchronized across all clients. To see how this works, you can either search the forum (there are few hints about it) or take a look at the CountdownTimer which is included in the PUN 2 package. It basically uses the Custom Player Properties to notify other clients that the local client is ready and the Custom Room Properties to synchronize the start time of the countdown.

2018-11-28 18:26:09

Hi @Christian_Simon, thank you for your reply, Do you have example or any sample code to synchronize spawn character and Start Game using Custom Player Properties and Custom Room Properties? I am currently making a 3v3 arena brawl game but each player spawns in arena at different time thus the countdown timer for each player is different. I am confused how to fix this.

Thank you for your help and support

2019-04-05 08:33:36

Hi! There is a little problem with this PhotonNetwork.automaticallySyncScene + counter solution.
Sometimes players are not communicating with each other. This happens randomly. I have changed timeout variables to like 15 mins but problem still occurs.
The master client loads the scene when all players are ready in a room. When the room is loaded for master client the other players begin to load the same map too. Once they are in the room they send an RPC to master client with a boolean which is stored in a common script on GameManager GameObject.
Once each players are ready the countdown begins. This is working mostly but randomly one player's countdown does not start. I have even tried to make a scene loader scene which is small and non-master clients began to load almost the same time as master client but that method failed working in the end. It made more mess...
Can you please help how to fix this random communication error? Does it happen maybe because server rejects users after a while? We are testing the system from same country so huge Ping difference can not be there. We are in front of public update and it would be great to get rid of this problem.

Many thanks in advance

2019-04-05 12:59:52

@luxoid: Which version of PUN are you using? In PUN v2.9, we updated the workflow to fix some problems of v2.8.

When you say that some player's loading does not start, this may be due to running into a timeout (not being able to send and or receive messages). If you have a timeout of 15 min, the user may not realize being no longer connected.
Please debug if said client still gets updates/messages from the game (and just does not load).
Also check your conditions to start loading.

2019-04-05 14:26:17

@Tobias thank you for your reply. I didn't check about updates yet... I feel so dumb :smiley:
I am using still 2.5 so I began to do backup then will update PUN to latest to see if problem is gone.
Thanks a lot!

2019-04-05 19:29:13

@Tobias the very same is happening with the latest PUN v2.9 as well. Large scenes fail to load. Sometimes loading screen and spawning freezes, sometimes race countdown does not begin for 1 player. Even Player's nickname is not appearing in the race position table. I think RPC does not arrive but I will check it with Editor now.

2019-04-08 14:37:00

If you use PhotonNetwork.LoadLevel(), you don't need to send another RPC to sync loading.
Spawning freezes? I don't know how this is related to PUN, as I've never seen such a case.
How long do "large scenes" load? How do they fail? Anything in the player log or editor log??

2019-04-15 11:27:16

The RPC-s are there to make custom built drones spawning properly for each clients, so to make them visible for other players as well. I have sorted this out nicely in the recent days. Now there is no freezing anymore. Some functions weren't working perfectly and the delay of loading between clients made these errors.
Thanks for all your help! The recent version of PUN2 is working awesome!
I just have to make an auto disconnect from lobby when players are inactive and it is ready to be published.
Keep up the good work!

2019-04-16 09:03:27

Thanks for all your help! The recent version of PUN2 is working awesome!

You're welcome and great to know it's doing well for you!

Keep up the good work!

Dito! :)

If you like to, register the game for our showcases page:

Back to top