Photon Character control problem

Options
Hi I'm trying to make an online game in Unity using PhotonNetwork but I got a problem. Whenever the second player joins the game the first clients camera is switches to the second clients camera the second clients camera switches to the first clients camera. I'm using "photonView.IsMine" to control the clients. This is my script :


private CharacterController controller = null;
public float speed = 6f;
public float turnSmoothTime = 0.1f;
float turnSmoothVelocity;
public Transform cam;
public Animator anim;

Vector3 moveVector;
private void Start()
{
controller = GetComponent<CharacterController>();

}
private void Awake()
{
if (!photonView.IsMine && GetComponent<PlayerMovement>() != null)
{
Destroy(GetComponent<PlayerMovement>());
}
}
private void Update()
{
if (!photonView.IsMine)
{
TakeInput();
}

Comments

  • Tobias
    Tobias admin
    edited April 2021
    Options
    Make sure to instantiate this with a prefab only when in the room. Else, IsMine is true (but not making sense yet).
    Otherwise it looks good. I can't see the error.
    Which version of PUN 2 is this?