- Home /
Do Photon networked scene objects have to be instantiated?
Hello,
In my multiplayer game I have a bunch of moving platforms that the players must jump across. I figure the best way to make sure the platforms are in sync between all of the players is to network the platforms. However, do I have to go through the PhotonNetwork.InstantiateSceneObject() call to have my networked objects in the scene?
The placement of the platforms through the editor is very specific and at-times painstaking. Grabbing all of their spawn transforms would be tedious and might break certain start functions in the game. So, is it possible to just give them photonViews in the scene and assume it will work?
Thank you.
Answer by ChristianSimon · Mar 13, 2018 at 10:48 AM
Hi,
yes, having those objects already placed in the editor is possible. They will be handled as Scene Objects this way.
Thanks for the response.
I'm still not too clear on this however. I have in my scene many moving platforms. Each platform has 3 main components: 1. A script that moves it (non networked). 2. A PhotonView 3. A PhotonTransformView In my scene, my platforms all have their respective PhotonTransformViews referenced in the "Observed components" of their PhotonView. Yet I'm getting an error like this when my second player joins:
The observed monobehaviour ($$anonymous$$ovingPlatform) of this PhotonView does not implement OnPhotonSerializeView()!
For each one of my networked platforms. In game, the non-master clients see my platforms move in a stall-stutter fashion. When I remove the observed component reference, I no longer get the error, but also my platforms are not synced.
Is there some kind of rule that you have to instantiate it over the network to utilize PhotonTransformView or something?
The script that actually process the movement of the platform should not be added as an Observed Component. If this is currently the case, please remove this component from the list of Observed Components. Also when updating the platform, make sure that this step is surrounded with a if (photonView.is$$anonymous$$ine)
condition to avoid updating the object on non-$$anonymous$$asterClients in this case.
Is there some kind of rule that you have to instantiate it over the network to utilize PhotonTransformView or something?
No.
After playing around with it more, I think that bug was co$$anonymous$$g from somewhere else. I ended up placing my networked prefab in the Resources folder and that seemed to fix it.
Thanks for the assistance!