- Home /
PUN2 photonView.IsSceneView returns true after ownership has been transferred to player
Hello,
I am using the following code to transfer the ownership of a photonview to a player when he connects.
public class PlayerConnection : MonoBehaviourPunCallbacks
{
public static bool OwnsPhotonView = false;
private void Start()
{
if (!OwnsPhotonView && this.photonView.IsSceneView)
{
photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
OwnsPhotonView = true;
}
}
}
I am using a static OwnsPhotonView
variable because there are two separate objects on the scene that have this code, and I want to make sure each player only controls one.
The objects are manually placed on the scene and set as "Takeover".
When the master client starts the room, he naturally takes ownership of the photonView. The problem is that when another client joins the room, the value of IsSceneView is true, and they then take back the ownership for themselves.
How can I make sure the info about the ownership is visible to the other player when he joins?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612224155im_/https://answers.unity.com/themes/thub/images/avi.jpg)