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
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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Scene Loading: Additive Scene Loading Questions

JoaoBorks
2017-11-09 17:48:52

Hey everyone! I'm building quite a complex game here and I'd like a few tips about some of the structure. First of all, we have the entire game lobby on one scene, and the plan is to load the game scene after everyone joins the room and gets ready. We could use PhotonNetwork.automaticallySyncScene with no issues, but we'd like to have a loading bar for everyone and these sort of things. If it was singleplayer we'd probably do it by loading the scene additively, but I have no clue on how to achieve that with Photon.

My second question is, at some point in the game, some of the players will have to play minigames, isolated from the others, and that would probably require another scene too. What should I do in this case?

Thanks!

Comments

[Deleted User]
2017-11-14 09:52:02

Hi @JoaoBorks,

asynchronously scene loading requires a custom solution. Maybe I can give you some input. You have different possibilities to tell other clients to load a certain scene. On the one hand the MasterClient can use the RaiseEvent function to raise an event for each client in the room, on the other hand he can use the Custom Room Properties to notify all clients in the room. Since in my opinion the first option seems to be the better solution, I will continue with this example. Whenever a client now receives the event telling him to load the game scene - if you have multiple game scene, the event can also contain the name of the scene - he can load the 'transition' scene and starts loading the game scene asynchronously. When the client's loading process is done - there is a callback telling you that it's done - the client can for example set a Custom Player Property or again raise another event to notify other clients - especially the MasterClient - that he is ready. The MasterClient needs to evaluate the information and can start the game based on those information.

To the second question: you can either load the minigame scene asynchronously, too, or simply load it separately. Both ways, please make sure, that the coordinates of the level elements are not overlapping with the main scene or each other scene, because you will still have networked objects that can be seen by all clients in the same room.

JoaoBorks
2017-11-14 13:24:54

Thanks @Christian_Simon ! I will try this out

[Deleted User]
2017-11-16 16:23:19

Hi @JoaoBorks,

I thought again about the topic and asked myself, if one of us has mixed something up with the terms: you have asked if there is a solution for additive scene loading and I gave some input for asynchronous scene loading. Well, in the end I guess both are working similar but there is of course a difference between both options.

In your case, I would still use asynchronously scene loading for switching from the menu to the game scene in order to have the 'transition' scene for displaying a loading bar. For the minigame scene I think both option will work: you can either load the scene asynchronously which requires you to load the game scene again after the minigame has ended or you can load it additively and unload it again after the minigame has ended. If it doesn't affect performance too much, the second way seems to be the better option in my opinion.

JoaoBorks
2018-01-08 17:21:30

It works, thanks a lot!

xblade724
2019-05-26 13:05:47

Whew, async is almost necessary in 2019: I've had negative reviews just for some freezing while loading. I got all my additive/async scenes setup with a nice buffer "Start" scene, then .... gah, forgot about Photon.

Thanks for the tips -- What EXACTLY does the Photon wrapper load level do that's extra to sync clients? It's essentially a master calling an RPC to say "also load this scene and turn off msg queue"? Anything else?

Can I just make an Rpc for everyone to load level additively async at the same time and it would essentially be the same?

Also, with additive + async, I probably don't need to turn off the msg queue?

Baja
2020-09-22 15:21:35

@xblade724 wrote: »

Whew, async is almost necessary in 2019: I've had negative reviews just for some freezing while loading. I got all my additive/async scenes setup with a nice buffer "Start" scene, then .... gah, forgot about Photon.

Thanks for the tips -- What EXACTLY does the Photon wrapper load level do that's extra to sync clients? It's essentially a master calling an RPC to say "also load this scene and turn off msg queue"? Anything else?

Can I just make an Rpc for everyone to load level additively async at the same time and it would essentially be the same?

Also, with additive + async, I probably don't need to turn off the msg queue?

  • same question here. bumping this

JoaoBorks
2020-09-22 18:41:00

@Baja in essence, you will want to handle the scene loading by yourself with the use of RPCs since the Photon framework does not natively implement any methods to handle multiple scene management or async scene load.

Baja
2020-09-23 15:40:36

@JoaoBorks wrote: »

@Baja in essence, you will want to handle the scene loading by yourself with the use of RPCs since the Photon framework does not natively implement any methods to handle multiple scene management or async scene load.

Thanks for the explanation. Actually, that was not quite what I needed. My question was, what would happen if I implement it simply via RPC like this:

It seems to be working so far, see any catch?

JoaoBorks
2020-09-23 19:03:16

@Baja sorry for missing the point at first. But well, that's exactly what I did on my code as well, and it worked well for me.

Back to top