PunRPC Not working for me

Options
So I'm trying to create a VR multiplayer game and there is a bit of a problem... So... I'm trying to call a method with a Transform as a parameter
public void Attach(Transform hand)
    {
        _hand = hand;
        _pv.RPC("AttachToHand", RpcTarget.AllViaServer, hand);
        //AttachToHand(hand);
    }

    [PunRPC]
    void AttachToHand(Transform hand)
    {
        _hand = hand;

        DebuggingScript.instance.DisplayInfo(true, "Pick: " + this.gameObject.name);
        _rb.isKinematic = true;
        _rb.useGravity = false;
    }

    public void Detach()
    {
        //_hand = null;
        _pv.RPC("DetachFromHand", RpcTarget.AllViaServer);
    }

    [PunRPC]
    void DetachFromHand()
    {
        DebuggingScript.PrintInfo("The object: " + this.gameObject.name + " was released.");
        _hand = null;
        _rb.isKinematic = false;
        _rb.useGravity = true;
    }

The most interesting thing is that.... I call the Attach method from another class, no problem there... the _hand variable gets the value that I'm looking for, so no problem there, but when it comes to the AttachToHand method, that is not called at all. If I call it simply with the line commented (AttachToHand(hand)) that works ok but it works only locally, which I don't want.

The Detach method is called correctly though....

Any ideas why?

Comments

  • Keylon
    Options
    Im having the same problem. I think its a bug
  • DarkSealer
    Options
    pfff.... Do you have any idea if there's any way to work around that?
  • Tobias
    Options
    Check out your log. You will notice an error log saying:
    "Exception: Write failed. Custom type not found: UnityEngine.Transform"
    The callstack gives you:
    "ExitGames.Client.Photon.Protocol18.WriteCustomType"

    The problem here is that Transform is not a serializable type for PUN. It can not send it. The reason for that is actually, that it's not possible to recreate the transform on the receiver side.
    What you really want to send is the ID of the object you want to attach to. The Transform is just a vehicle for that but .. one that does not work in the networked world of Unity.

    Find an ID, convert it to something send-able (for PUN) and on the receiving end, find the transform that relates to said send-able ID. Then use that.


    And yes, locally, the call will work. It's the same runtime and the transform is not passed around as serialized data. Instead, we call the RPC method right away and things seem to work.

    Sorry for the confusing handling of this!
  • DarkSealer
    edited June 2020
    Options
    ooooh.... I see. The problem is that I'm developing an app for Oculus Quest so I can't see the errors. I found a way to solve my challenge, but that's very good to know. Thanks.
  • GarvGoel_77
    edited June 2020
    Options
    good
  • Tobias
    Options
    Any way to get the logs from the Quest? We log a lot of (more or less) useful stuff, when there are errors. At least when things don't work, have a look at the logs.
    Last but not least: This reproduces in the Editor, too.
  • DarkSealer
    Options
    Well... yes and no. For some reason only some errors will find their way to the console through the network. How did you do that? How did you got those stuff from quest?