【发布时间】:2020-04-18 18:23:06
【问题描述】:
我认为 Photon 和鼠标位置之间存在问题。因为当我尝试使用键盘更改对象的位置时,它可以成功运行,但是当我尝试使用鼠标更改位置时,它并没有通过网络进行更改。如何在网络上通过鼠标位置更改对象位置?
public class SpehreControl : MonoBehaviour
{
PhotonView PV;
GameObject sphere1;
GameObject bt;
// Start is called before the first frame update
void Start()
{
PV = GetComponent<PhotonView>();
sphere1 = GameObject.Find("Sphere 1");
bt = GameObject.Find("BT_1");
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0) && PV.IsMine)
{
PV.RPC("RPC_MoveOnline", RpcTarget.AllBuffered);
}
}
[PunRPC]
void RPC_MoveOnline()
{
transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x,
Camera.main.ScreenToWorldPoint(Input.mousePosition).y, 0);
}
}
【问题讨论】:
标签: c# unity3d networking multiplayer photon