Synch Y rotation over photon network aswell.

Options
Hey guys,

First of i want to thank the makers of photon for this awesome system i love it ;)

I do have question however, I have made this multiplayer game where people can just walk around for now. I stream the position and the rotation like this:

using UnityEngine;
using System.Collections;

public class networkCharacter : Photon.MonoBehaviour {

Vector3 realPosition = Vector3.zero;
Quaternion realRotation = Quaternion.identity;

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {
if( photonView.isMine ) {

}
else {
transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f);
}
}

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}else {
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
}

}
}





But now the problem is it send over the X and Z rotation, but not the Y rotation.

How do i synch this over the network with this script.

thanks in advance,

-v3

Comments

  • vadim
    Options
    Hi,

    How did you find out that Y rotation is not sent?
    Can you log what is in transform.rotation before sending? Does it contain required rotation?
    Check if synchronization via making object's transform observed by PhotonView works for you. No OnPhotonSerializeView required in this case.
  • v3n0mou5
    v3n0mou5
    edited November 2015
    Options
    Hey,

    i figured it out, thx anyway for the help, the photonview was not used properly.

    Can i ask another question here or do i need to open a new post?

    anyway the question is:

    i use the master client to instantie a gameobject.

    if all players are in the room at the time of the instantiation. everything is alright,

    but when a player joins after the instantiation. he doesnt see the gameobject. it just appears real quick befor changing scene.

    im already using the photonnetwork.loadlevel.


    im using Photon with UFPS

    thanks in advance,

    -v3
  • Tobias
    Options
    If you create a new thread for a new topic, this will improve your chances of someone finding your topic. Aside from that: be our guest :)

    PhotonNetwork.LoadLevel uses isMessageQueueRunning to pause PUN from dispatching incoming messages. So: When you join, it first checks the scene property and immediately pauses the queue, if another level needs to be loaded.
    Make sure you don't set isMessageQueueRunning. Also, make sure you don't accidentally load levels anywhere else.

    Let us know which version of PUN you use.