OnPhotonSerializeView() not getting called.

Options
I'm following the Monster tutorial, trying to apply it to my own code, but OnPhotonSerializeView() is not getting called.

I have a "Scripts" GameObject that has a RandomMatchmaker.cs component that instantiates a prefab:

[code2=csharp]public class RandomMatchmaker : Photon.MonoBehaviour {

//...

void OnJoinedRoom() {
GameObject mini = PhotonNetwork.Instantiate("MiniPrefab", new Vector3(3.0f, 3.0f, 3.0f), Quaternion.identity, 0);
}

//...
}[/code2]

That prefab has a PhotonCharacter component:

[code2=csharp]public class PhotonCharacter : Photon.MonoBehaviour {

//...

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
Debug.Log ("OnPhotonSerializeView()");
// ...
}
}[/code2]

When I build and run, and have the editor version going, I can move the character in one app and see it move it the other, and vice versa, so that is all working, but I'm trying to smooth out the movement as suggested in the tutorial.

How can I ensure that OnPhotonSerializeView() gets called?

Comments

  • Tobias
    Options
    Select the prefab in the inspector and drag and drop the script onto the PhotonView's "Observe" item.
    This sets the PhotonView up to call OnPhotonSerializeView on this script.

    The alternatives would be to just sync the transform or nothing at all.
  • TapOnFire
    Options
    Thanks, OnPhotonSerializeView() gets called now. This wasn't clear to me in the tutorial.
  • dreamora
    Options
    TapOnFire wrote:
    Thanks, OnPhotonSerializeView() gets called now. This wasn't clear to me in the tutorial.

    This behavior is the same as it is for Unity networking actually :)
  • TapOnFire
    Options
    dreamora wrote:
    This behavior is the same as it is for Unity networking actually :)
    Ah... that explains it. I've never used Unity networking, I went straight to Photon. I guess I'll read up on Unity networking too.
  • Hey guys,

    can anybody tell me, why my object that have the OnPhotonSerializeView() attached, starts at position 0,0,0?
    [EDIT: Double post from here: viewtopic.php?f=17&t=2374&p=11163#p11136]
  • Tobias
    Options
    Please no double posting. You can't expect a faster answer due to many posts. The same few helpful people will try to read and answer, no matter how often you post.