synchronize the rotation

Options
Hi everyone, I'm starting with Photon. I wanted to understand how I can synchronize a rotation. In my game I have 2 players who rotate their weapon in the direction of the mouse. This is the code I made for the single player. I should do a PUN function for rotation so that each player sees where the other is pointing. How should i do?
    void Update()
    {
        mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition);
        posScreen = Camera.main.WorldToViewportPoint(gunPivot.position);
        mousePos.z = 0;
        
        Vector3 dir2 = (posScreen - mousePos).normalized;
        gunPivot.rotation = Quaternion.LookRotation(Vector3.forward, mousePos - posScreen) * Quaternion.Euler(0,0,90);
        Debug.DrawRay(gunPivot.position, dir2 * 10, Color.red);
    }

Comments