Updating photonView.instantiationData at runtime
I have lots of small objects in my world which I create using PhotonNetwork.InstantiateSceneObject. I use the photonView.instantiationData to store initial setup data for them. Sometimes this data may change over time and I would like to be able to adjust this instantiation data to reflect these changes. Is it possible to change/update the instantiation data after an object has been created? I could send these changes with an RPC but it would be nice to just be able to update the instantiation data.
Thanks
Answers
-
bump.. anyone?
0 -
the design of instantiation data is only for instantiation I guess, maybe you can use customProperties from PhotonPlayer class. this customProperties hash is auto updated over network0
-
"photonView.instantiationData" Initialized only once during the creation of the network prefab. It can not be reassigned.
You can create a special variable that is passed, for example, through OnPhotonSerializeView in each object if the state changes very often.
You can create a room property in the form of a line in which all the states are listed But there is a problem in its editing when these objects are deleted or added
Similarly, property master client in the form of a line. Only it will have to be passed on to the new master client via the callback OnMasterClientSwitched
You can save traffic and process it all only when a new player enters. - OnPhotonPlayerConnected (PhotonPlayer newPlayer) . But there may be a desync at this point. If the scene objects are actively changing their state at the time of transfer, or new scene objects are added or deleted .
There is a solution to this problem - just lock the screen to all players. So that they do not interfere and do not spoil the data transfer to the new player about the changed states of the scene objects
0 -
You can create a special variable that is passed, for example, through OnPhotonSerializeView in every scene object if the state changes very often.
You can create a room property in the form of a line in which all the states are enumerated. But there is a problem in its editing when these scene objects are deleted or added
Similarly, property master client in the form of a line. Only it will have to be passed on to the new master client via the callbackOnMasterClientSwitched(PhotonPlayer newMasterClient)
You can save traffic and process it all only when a new player enters. callback -OnPhotonPlayerConnected (PhotonPlayer newPlayer)
But there may be a desync at this point. If, at the time of transfer, scene objects actively change their state, new scene objects are deleted or added
There is a solution to this problem - just lock the screen to all players. So that they do not interfere and do not spoil the data transfer to the new player about the changed states of the scene objects0 -
So, does that mean overtime I change any property for a photon player, it will get reflected for the same user all over the network??WenderRondonia said:the design of instantiation data is only for instantiation I guess, maybe you can use customProperties from PhotonPlayer class. this customProperties hash is auto updated over network
0 -
How do I lock the screen for all the players? I believe this is not possible because I cannot control every player's activity.Kurtav said:You can create a special variable that is passed, for example, through OnPhotonSerializeView in every scene object if the state changes very often.
You can create a room property in the form of a line in which all the states are enumerated. But there is a problem in its editing when these scene objects are deleted or added
Similarly, property master client in the form of a line. Only it will have to be passed on to the new master client via the callbackOnMasterClientSwitched(PhotonPlayer newMasterClient)
You can save traffic and process it all only when a new player enters. callback -OnPhotonPlayerConnected (PhotonPlayer newPlayer)
But there may be a desync at this point. If, at the time of transfer, scene objects actively change their state, new scene objects are deleted or added
There is a solution to this problem - just lock the screen to all players. So that they do not interfere and do not spoil the data transfer to the new player about the changed states of the scene objects
and even if someone tries to modify its property, then most of the times, the screen of every player will get locked.0 -
How do I lock the screen for all the players? I believe this is not possible because I cannot control every player's activity.
and even if someone tries to modify its property, then most of the times, the screen of every player will get locked.
I'm talking about the property of the room. Every player, look at this property. If someone has changed it into the true. So it tells all the other players to open the UI panels on top of the screen, etc. Because they see how someone changed the property of the room to the true.0