【发布时间】: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