The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

RPC method not found

2021-07-29 14:41:33

Using RPC throws an error:

RPC method 'HandleHumanoidDead(Boolean)' not found on object with PhotonView 1018. Implement as non-static. Apply [PunRPC]. Components on children are not found. Return type must be void or IEnumerator (if you enable RunRpcCoroutines). RPCs are a one-way message.

The method is not static, there's no same named method, the parameter is correct, and photonView exists, and the script is attached in the game object that both have photonView and this script, and also has [PunRPC] attribute.

I only tested with offline mode and but it is supposed to work here too.

Here's the code:

Already tried to clear and refresh the RPC list, but doesn't make any change. Unity 2019.1.0f2 and PUN2


2021-07-29 14:52:23

Only I can guess that there is a possible factor that may be related to this issue: the above script was inherited from the class that inherits MonoBehaviourPun, and the actual using component is also inherited.

public abstract class BaseCharacterController : MonoBehaviourPun
-> public class HumanoidBaseController : BaseCharacterController <- Above codes are here
--> public class HumanoidCharacterController: HumanoidBaseController <- Used component in the gameobject

2021-07-29 15:24:43

I just put the additional codes in PhotonNetworkPart.cs, after line 494

As I expected, the RPC method wasn't there. Only the [PunRPC] method in the classes at the final level of the inheritance structure came out.

How to fix this? HumanoidBaseController is already used in the multiple Humanoid type characters in my game, includes players, various types of AI units. The HandleHumanoidDead RPC must be invoked from the HumanoidBaseController, not the subclasses. Any ideas?

2021-07-29 15:34:33

I'm not sure this is the right way to do it, but actually, I found the solution.

Changed this in HumanoidBaseController from these:

To these:

And then move to the child class(in my case, HumanoidCharacterController and PlayerController), add these:

Now calling HandleHumanoidDead as an RPC from the parent class will invoke the method in the child.

2021-07-30 10:46:32

If the RPC method is overridden, do not forget to add the PunRPC attribute to it. Otherwise, inherited methods not overridden that have PunRPC attribute on the base class can be used.

from doc page

2021-07-30 13:35:49

Thanks for the clarification.

Back to top