OnPhotonSerializeView() not getting called.
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
OnPhotonSerializeView() not getting called.
TapOnFire
2013-01-25 04:36:03
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
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.
Thanks, OnPhotonSerializeView() gets called now. This wasn't clear to me in the tutorial.
@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 :)
@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]
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.
Back to top