Photon Unity Networking: PhotonRigidbody2DView Class Reference

Photon-Unity-Networking

PhotonRigidbody2DView Class Reference

This class helps you to synchronize the velocities of a 2d physics RigidBody. Note that only the velocities are synchronized and because Unitys physics engine is not deterministic (ie. the results aren't always the same on all computers) - the actual positions of the objects may go out of sync. If you want to have the position of this object the same on all clients, you should also add a PhotonTransformView to synchronize the position. Simply add the component to your GameObject and make sure that the PhotonRigidbody2DView is added to the list of observed components More...

Inherits MonoBehaviour, and IPunObservable.

Public Member Functions

void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info)
 Called by PUN several times per second, so that your script can write and read synchronization data for the PhotonView. More...
 

Detailed Description

This class helps you to synchronize the velocities of a 2d physics RigidBody. Note that only the velocities are synchronized and because Unitys physics engine is not deterministic (ie. the results aren't always the same on all computers) - the actual positions of the objects may go out of sync. If you want to have the position of this object the same on all clients, you should also add a PhotonTransformView to synchronize the position. Simply add the component to your GameObject and make sure that the PhotonRigidbody2DView is added to the list of observed components

Member Function Documentation

void PhotonRigidbody2DView.OnPhotonSerializeView ( PhotonStream  stream,
PhotonMessageInfo  info 
)

Called by PUN several times per second, so that your script can write and read synchronization data for the PhotonView.

This method will be called in scripts that are assigned as Observed component of a PhotonView.
PhotonNetwork.sendRateOnSerialize affects how often this method is called.
PhotonNetwork.sendRate affects how often packages are sent by this client.

Implementing this method, you can customize which data a PhotonView regularly synchronizes. Your code defines what is being sent (content) and how your data is used by receiving clients.

Unlike other callbacks, OnPhotonSerializeView only gets called when it is assigned to a PhotonView as PhotonView.observed script.

To make use of this method, the PhotonStream is essential. It will be in "writing" mode" on the client that controls a PhotonView (PhotonStream.isWriting == true) and in "reading mode" on the remote clients that just receive that the controlling client sends.

If you skip writing any value into the stream, PUN will skip the update. Used carefully, this can conserve bandwidth and messages (which have a limit per room/second).

Note that OnPhotonSerializeView is not called on remote clients when the sender does not send any update. This can't be used as "x-times per second Update()".

Implements IPunObservable.

Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH