Fusion and handling async loading prefabs that contain network objects
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
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).
Fusion and handling async loading prefabs that contain network objects
SalehOOI
2022-07-19 17:07:26
I am building a scene that consists of tiles in a 9x9 grid.
Each tile is a prefab and has objects within, imagine buildings, doors, trees. In each tile, we could have network objects, if there's a specific door that we want synchronized between everyone, it would have a network object, and network behaviours related to it.
If i just dragged all the tiles to the scene, and set them there manually in a 9x9 grid, Fusion can easily just fill in the Baked Data in each network object when i save the scene.
However, I need to load these tiles asynchronously, and have been able to load them through addressables. I have a synched random generator, so I am 100% confident in that all clients will load in the same prefabs, in the same place, and in the same order.
Obviously due to the tiles being loaded asynchronously at runtime and not through being instanced in the scene itself, there is no Baked Data, and I get the message:
InvalidOperationException: Behaviour not initialized: Object not set.
If I know that these tiles are going to be loaded in the same sequence in the same place, what's the best way to approach this? Loading prefabs asynchronously not in any scene, while maintaining that each network object inside is properly matched.
One way we thought of was to make each tile a scene instead but that isn't practical since we'd have to go through every prefab and turn it into a scene.
I thought of using Spawn Object, but it didn't make sense in this scenario, as the tile prefab itself isn't a network object, it just has some instances of networked objects.
Is there a possibility that i can replicate the same process that scenes go through to get all their network data baked but on prefabs i've set?
I do come from PUNv2, so I may have a misunderstanding about how a specific system would work.