Photon Players controlling each other

Before anyone says this has already been answered, it does not work for my code.
I recently added multiplayer to my 3d game. I followed a tutorial and I have an issue. Player A is controlling player B and player B is controlling player A. They are swapped and it is annoying me. Here is the code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;


public class PlayerMove : MonoBehaviour
    public float walkingSpeed = 7.5f;
    public float runningSpeed = 11.5f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;
    public Camera playerCamera;
    public float lookSpeed = 2.0f;
    public float lookXLimit = 45.0f;
    PhotonView photonView;
    public Animator walk;

    CharacterController characterController;
    Vector3 moveDirection =;
    float rotationX = 0;

    public bool canMove = true;
    void Start()
        characterController = GetComponent<CharacterController>();
        photonView = GetComponent<PhotonView>();
        // Lock cursor
        //lockCursor = Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;


    private void Awake()
        Cursor.lockState = CursorLockMode.Locked;
    void Update()
        if (photonView.IsMine)

            // We are grounded, so recalculate move direction based on axes
            Vector3 forward = transform.TransformDirection(Vector3.forward);
            Vector3 right = transform.TransformDirection(Vector3.right);
            // Press Left Shift to run
            bool isRunning = Input.GetKey(KeyCode.LeftShift);
            float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
            float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
            float movementDirectionY = moveDirection.y;
            moveDirection = (forward * curSpeedX) + (right * curSpeedY);

            if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
                moveDirection.y = jumpSpeed;
                moveDirection.y = movementDirectionY;

            if (!characterController.isGrounded)
                moveDirection.y -= gravity * Time.deltaTime;

            // Move the controller
            characterController.Move(moveDirection * Time.deltaTime);

            // Player and Camera rotation
            if (canMove)
                rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
                rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
                playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
                transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
            walk = GetComponent<Animator>();


It looks like the issue is with the way you are checking which player’s input to use. In the Update method, you are only allowing player input if photonView.IsMine is true, which means that the player’s input is only applied to the player who is “mine” or controlled by the local client.

However, if you want both players to be able to move independently, you should check if the player’s PhotonView is mine and use that player’s input, rather than checking if the PhotonView is mine and only allowing input for that player.

To fix this, you can add a check to see if the player’s PhotonView is mine before applying the input.