Unregister PhotonView locally

Options
Hello !

I'm currently facing a problem concerning the photonView component.

Here's my situation : Classic behaviour, I have 1 master and 2 clients (clientA and clientB) in a room. They all load a Game Scene when the master hits Play. In the scene I have a GameManager containing an Awake callback. In this callback, the 2 clients use the PhotonNetwotk.Instantiate(playerPrefab) function to instantiate their character. Their character own a Camera gameObject with a photonView on it. I'd rather delete locally clientB's camera on the clientA's application and vice versa, in order to avoid issues with multiple cameras. To do this, I use the MonoBehaviour.Destroy(cameraGO).

Here's my issue : Every time the cameraGO of the clientB is updated, the clientA still receives this modification in the form of a warning : Received OnSerialization for view ID XX. We have no such PhotonView!
This probably does not cause any issue yet, but I don't think that it's a clean situation for the application (stream flood, may cause some Timeout ?).

What I tried : I tried to call the function PhotonNetwork.LocalCleanPhotonView() but with no success (both before and after destroying the gameObject).

So is there any clean way to 'unregister' the callbacks from a photonView that still exist on the server but not locally ?

Thanks.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2019
    Options
    Hi @Clemanza,

    Thank you for choosing Photon!

    Every time the cameraGO of the clientB is updated, the clientA still receives this modification in the form of a warning : Received OnSerialization for view ID XX. We have no such PhotonView!
    My guess is that you have a PhotonView attached to the same GameObject as the Camera, why do you need this? if you don't just get rid of it or instead of MonoBehaviour.Destroy(cameraGO) do a MonoBehaviour.Destroy(camera).
  • Hi @JohnTube ,

    As you guessed, there is a photonView on the GameObject containing the camera.
    Clemanza said:

    Their character own a Camera gameObject with a photonView on it.

    A solution would definitely be to only remove the Camera (and AudioListener) component and keep the photonVIew component alive.
    However on a client, I don't need at all having the updates of the other client's camera GameObject.
    I forgot to mention that the Master Client does not remove the camera gameObjects of the other clients as it needs to display their game view.
    My thoughts were that it would be better to remove the photon view (as I don't need it on other client) in order to reduce the data received from the network stream, and (probably ?) avoid some network issues.