只要只有一个玩家,玩家移动就可以正常工作,但一旦其他玩家加入,它就会切换 PlayerMovement.cs
using UnityEngine;
using Photon.Pun;
public class playerMovement : MonoBehaviourPunCallbacks
{
public Rigidbody rb;
private Vector3 move;
public float moveSpeed = 5f;
public LayerMask layer;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
//Camera.main.enabled = false;
}
// Update is called once per frame
void Update()
{
if (!photonView.IsMine)
return;
move = new Vector3(Input.GetAxisRaw("Horizontal"),0,Input.GetAxisRaw("Vertical"));
//move = move.normalized;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(move), 0.15F);
move = move * moveSpeed;
//transform.Translate(move*Time.deltaTime,Space.World);
}
private void FixedUpdate()
{
if (!photonView.IsMine)
return;
rb.position+= move*Time.fixedDeltaTime;
//rb.MovePosition(move*Time.deltaTime);
}
}
这是显示问题的视频 https://youtu.be/nqeRZyFHRpc 是的,如果有人认为其中存在问题,我正在使用 PhotonNetwork.Instantiate
答案 0 :(得分:0)
好的,添加一个 SetActive 来停用不属于玩家的相机 成功了。