Problem using PhotonViews from the Photon Plugin

I’m having trouble getting my PhotonView setup to work. I have verified that RPC’s work in my program, and have verified that the overall server/client setup is working. I have also gotten the demo unity project included in the plugin as well as the Viking demo to work.

I have attached a PhotonView object to my prefab, and dragged my Controller script which derives from Photon.MonoBehavior into the “Observe” property of the PhotonView object. I set the “ObserveOption” property to ReliableDataCompressed. Within my Controller script, I’ve implemented the OnPhotonSerializeNetwork() function. I’ve setup a Debug.Log() statement as my first statement within this function, and noticed that it is never outputed in Unity and basically that the OnPhotonSerializeNetwork() function is never called in my program. Again, I am able to successfully call RPC’s, and am sure my program is able to communicate with the master server and basically that my server side setup is correct.

I’ve gotten my program to work successfully over the network when using Unity’s normal NetworkView setup, but am unable to do it now with the PhotonView implementation.

Anyone have an idea what the problem might be or encountered a similar problem? Thanks in advance.

I am having a similar problem. The thing is that the game instance that created the room is the only one that is able to write to the stream. I am having one game instance that is a web game and the other is from the editor. The one that creates the room, if it changes, it writes to the stream and the other reads and gets updated. But the first won’t update if the second has its value changed. Did you solve your problem?

Moo,
the “Worker Demo” from the Photon Unity Networking package has a ThirdPersonNetwork.cs
In it, we have:

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
Debug.Log(“serialize”); // just added this, like you

If you actually implemented “OnPhotonSerializeNetwork”, it’s no wonder it’s not called.

MorphVGX,
Your problem seems to be somthing else. Each PhotonView belongs either to the scene or to a player.
If it has an owner, only this owner is able to write (change) to the stream. If a PhotonView belongs to the scene (setup in the scene’s hierarchy), only the master player will be able to change this view and send changes.

The Editor’s Inspector will show each PhotonView’s owner. “Scene” or otherwise.

Oh… that’s great to know. Thank you very much TobiasS =D

One thing… how do I change the owner? :face_with_spiral_eyes:

At the moment, you can’t change the owner.
Scene PhotonViews exist in the scene and are “owned” by the MasterClient. Anyone else is not able to change them. It would become quite difficult to keep a consistent state if more than one client change values at the same time.

Hi Tobias, since I’m having a similar problem, and is 2013 now, I wanted to know if this had changed.
I’m building a card game. And the “community cards” are shared between users. Each turn, a player can interact with those cards, play etc. Once his turn is over, another player takes control of the cards.
I can’t seem to find another way of doing this, that doesn’t involve destroying the objects, and make the user create them again for every turn.
Did this change?
Or is there a way of doing this?

Sorry, but we still don’t support changing control.

In your case, I’m not sure if I would implement cards with a PhotonView each. Are you monitoring any info about the card, like where it moves or something? It’s pretty static and the whole game state shouldn’t be so complicated, so you might skip all PhotonViews except one and use that to send state and actions through RPCs maybe. The player who’s in control can be defined as room property, which the active player or the master client will modify when necessary (next turn or when the active player leaves).

Hi, thanks for answering, well, I guess I went the right way. I kinda handle it as you just said.
A single photon view will handle most of the game. And I added a photon view for every card so the users can see it moving when they play them. Altough I had to make the position syncing with RPCs because I can’t change the owner of the card to use the built in OnPhotonSerializeView.
And yes, master client is who dictates and sets up everything.
thanks again tobias!