【问题标题】:Unity3d Photon character movement not synchronousUnity3d Photon角色移动不同步
【发布时间】:2014-05-03 15:28:49
【问题描述】:

我是 unity3d 上的光子初学者。我想在游戏中同步移动角色。我将脚本作为观察者附加到光子视图并使用此代码

void OnPhotonSerializeView(PhotonStream stream,PhotonMessageInfo info)
{
    if (stream.isWriting)
    {
        Debug.Log("writing");
        stream.SendNext(transform.position);
        stream.SendNext(transform.rotation);

    }
    else
    {
        Debug.Log("reading");
        this.correctPlayerPos = (Vector3)stream.ReceiveNext();
        this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
    }
}

问题是创建房间的玩家可以改变玩家的位置和旋转,它只能写。但是第二个玩家(加入房间)不能改变位置和旋转,它只能阅读。 我的设置可能有什么问题。

为此,我已按照马可波罗教程 (http://doc.exitgames.com/en/pun/current/tutorials/tutorial-marco-polo)。任何帮助都非常感谢。

【问题讨论】:

    标签: unity3d multiplayer photon


    【解决方案1】:

    如果您通过 PhotonNetwork.Instantiate 为每个玩家实例化一个游戏对象,那么每个客户端都有自己的游戏对象,该客户端可以为其编写更新。

    【讨论】:

      猜你喜欢
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多