PRC call error,when the two same components in a gameobject

Options
I have a component called shooter. And I have multi shooter components on my player game object. If I use PRC call shoot function of a shooter. It will cause an error, "NullReferenceException: Object reference not set to an instance of an object"

I think it caused by multi shoot function in the same gameobject, but I need many shooters in my player gameobject so I can stack many shooting ways up. How can I tackle this issue?


Answers

  • Scoz
    Options
    Does someone know how can I use RPCPun to call a function which is not just one in the same game object?
  • jeanfabre
    Options
    Hi,

    we are investigating this internally and will see if we can come up with something.

    right now, your best approach would be either to combine shooters in one component featuring a list of shooting properties, then you have one RPC. or have a proxy "Shooters" that receive the RPC and forward all to all shoot components found on that gameobject. Shoot component would not implement the rpc method directly.

    Bye,

    Jean
  • Scoz
    Scoz
    edited August 2019
    Options
    OK, thanks for your suggestion. I will try.
  • jeanfabre
    Options
    Hi,

    yes, I got the confirmation that we won't support this, it's by design, so indeed make a proxy to catch the rpc and dispatch yourself after.

    Bye,

    Jean
  • Scoz
    Options
    Got it, thank you.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2019
    Options
    Hi @Scoz,

    Thank you for choosing Photon!

    The fix for the NullReferenceException will be there in the next PUN2 version.
  • Scoz
    Options
    OK, thank you!