Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question XRGrabInteractable & Pun2 - Gameobject sync issue

Discussion in 'Multiplayer' started by Manali_26, Jan 24, 2023.

  1. Manali_26

    Manali_26

    Joined:
    Mar 21, 2022
    Posts:
    1
    I have been trying to use XR Toolkit and Photon 2 Networking to create a multiplayer experience. When Player A grabs an object using XRGrabInteractable it looks fine. Player B, watching that interaction - vice versa.

    When Player B grabs the object from the player A hands, for Player B object is in hand and for Player A object is still in the hand (When grabbed from either players hand, object is not syncing in network - both players think they are holding the object)

    public class XRGrabNetworkInteractable : XRGrabInteractable

    {

    private PhotonView photonView;

    private void Start()

    {

    photonView = GetComponent<PhotonView>();

    photonView.OwnershipTransfer = OwnershipOption.Takeover;

    }

    protected override void OnSelectEntered(XRBaseInteractor interactor)

    {

    photonView.RequestOwnership();

    base.OnSelectEntered(interactor);

    }

    }

    upload_2023-1-24_20-24-36.jpg