This can't be used as "x-times per second Update()". Note that OnPhotonSerializeView is not called on remote clients when the sender does not send any update. Used carefully, this can conserve bandwidth and messages (which have a limit per room/second). If you skip writing any value into the stream, PUN will skip the update. It will be in "writing" mode" on theĬlient that controls a PhotonView (PhotonStream.isWriting = true) and in "reading mode" on the remote clients that just receive that the controlling client sends. To make use of this method, the PhotonStream is essential. Unlike other callbacks, OnPhotonSerializeView only gets called when it is assigned to a PhotonView as PhotonView.observed script. Your code defines what is being sent (content) and how your data is used by receiving clients. Implementing this method, you can customize which data a PhotonView regularly synchronizes. ndRate affects how often packages are sent by this client. ndRateOnSerialize affects how often this method is called. Learn more about Netcode for GameObjects. This method will be called in scripts that are assigned as Observed component of a PhotonView. We’re evolving our solution, built on Netcode for GameObjects, in the open to become a netcode foundation that you can depend on customizable and extensible to meet the needs of many multiplayer game types. M_ScaleModel = new PhotonTransformViewScaleModel()Ĭalled by PUN several times per second, so that your script can write and read synchronization data for the PhotonView. M_RotationModel = new PhotonTransformViewRotationModel() M_PositionModel = new PhotonTransformViewPositionModel() OnPhotonSerializeView ( PhotonStream stream, PhotonMessageInfo info)Ĭalled by PUN several times per second, so that your script can write and read synchronization data for the PhotonView. at 100 players you'd hit 40Mbps on the server at that update rate with just a single transform per player being synced. at 50 players you get 49x50x36x15 10Mbps worth of bandwidth for the server (Still acceptable). Your movement script should pass on the current speed (in units/second) and turning speed (in angles/second) so the remote object can use them to predict the objects movement. with 20 players at the same updaterate you get 19x20x36x15 1600kbps (80kbps per player) (now its no longer possible to host the game on a DSL connection with 1Mbps upload, players can still play just fine with even a really weak 256kbps connection). These values are synchronized to the remote objects if the interpolation mode or the extrapolation mode SynchronizeValues is used. SetSynchronizedValues (Vector3 speed, float turnSpeed) Inherits MonoBehaviour, and IPunObservable. Simply add the component to your GameObject and make sure that the PhotonTransformView is added to the list of observed components It also gives you many different options to make the synchronized values appear smooth, even when the data is only send a couple of times per second. This class helps you to synchronize position, rotation and scale of a GameObject.
0 Comments
Leave a Reply. |