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
Documentation

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.

Read More on
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.

ERROR You have missing MonoBehaviours on your gameobjects!

Necka
2021-04-23 16:13:42

Hello,
So after literally days of troubleshooting this issue, I'm giving up and want to try getting some help here.

Unfortunately, I searched this error here and didn't really get an answer for my issue.

I'll try to put as much context as I can to avoid that you miss important information to help me:

Scenes setup:
"A": Main Menu scene
"B": Lobby Scene

There is then a play scene but this doesn't matter anymore as the error only comes in the lobby scene because of the first Player models instantiation.

In Scene "A", Player 1 through the UI can create a room. there are no Photon involved here, clicking on the Create room button setup a bunch of variables and Load Scene "B"

In Scene "B", Player 1 through a lobby script, creates the Room. Then in the network manager it uses the photon Callback

In there it checks if we are Master Client, if yes we setup some room props and trigger then the instantiation of the Player Prefab using of course:

From the point in time, everything works perfectly fine

At this point, Player 2 decides to join the game. Same, Scene "A", only UI without any photon magic in this scene, it just save the room name variable and Load Scene "B" (I tried with PhotonNetwork.LoadLevel("sceneName") too)

In that scene Player 2 Join the room and that's where the disaster starts!

As soon as we join the room I get the error message. I know the error is longer that usual but I added some stuff in the Debug.Log to try to pin point what RPC was the cause from where to who etc.

As previously stated, here Player 2 through the OnJoinedRoom() Photon callback check if were are master and as it's not, it just go straight to instantiating his own Player Prefab.

The error happens before the instantiation of the Prefab. And that's where I understand why. The RPC is supposed to be received from a component that's on the Player Prefab. I didn't instantiate it yet, so it can't receive it.

The fun part of course is that this error is triggered only once and that absolutely everything is working fine after the instantiation, there are no problems at all. Everything is synced etc. So you could say "ok just ignore the error and move on" But I have OCD with those red lines. It doesn't look professional in the Player Log either and I'm not accepting errors in my project, simple as that :)

More info:

The RPC is sent like this from this Character script located on the Player Prefab:

The RPC is received as:

At that point I have no clue on how to troubleshoot this issue anymore. Do be fully transparent, I'm using a Unity module which lift the heavy weight on the Photon side and allow me to do most things in a visual scripting way. But I do know my way around code but that's also the reason why I'm not sharing too much details on code here, but can answer any questions of course!

Thank you in advance for your support, I hope my post isn't too complicated to understand

Comments

JohnTube
2021-04-23 22:37:59

Hi @Necka,

Thank you for choosing Photon and for doing your homework fist then trying to provide as much details as possible.

What PUN version is this?
What Unity version is this?

Could you please post the exact error + stack trace without any modifications?

I'm not sure if "ERROR You have missing MonoBehaviours on your gameobjects!" this is from PUN?

What you guessed is probably right, the RPC is being received while the networked GameObject is either not instantiated, not instantiated yet or instantiated then removed.
This could be due to scene loading or a timing issue (race condition of some sort).

Necka
2021-04-23 23:17:11

Hello @JohnTube
So yes, I'm sorry I forgot to indicate those important information:
Pun 2 version 2.3.0
Unity 2020.3.5 LTS

The stack trace isn't modified, I just added a few info to the error message but without modification it's:

Yes the error message is from PUN, as you can see in PhotonNetworkPart.cs line 473

I am 100% sure that this is caused by the RPC being sent from the OnJoinedRoom() but the issue is that I saw that from multiple scripts not only from mine (like the asset: SmoothSync)

Basically let say on Player's 2 computer he arrives in this room that player 1 created.
So on Player's 2 computer, the Player 1 remote player prefab gets instantiated.
That when (I think) this remote Prefab send this RPC
But my Player 2 just arrived and has not yet instantiated its own Player Prefab so that's why it's throwing the error.

I kind of eliminated the load issue as I've just tried to do: Arrive in scene => JoinRoom("room") => do nothing. The error is triggered.

My problem is: I can't instantiate Player 2 prefab before being in the room as PhotonInstantiate() requires to be in a room (right?)

So I'm in this kind of brain loop right now where I kind of understand why it's happening but have absolutely no clue on how I could make it not happen... thus the days of troubleshooting, giving up and coming here for a clue :(

Necka
2021-04-24 01:13:35

A quick update, I noticed that if I do not use:

but instead use:

The problem doesn't exist anymore.

I guess as the prefabs use the same component with the photonview, it gets cached when Player 1 first create the room.

I'm wondering how I could avoid this issue now in terms of logic as refreshing the cache would probably not help. Or maybe I didn't understand how this works

JohnTube
2021-04-24 21:30:37

Hi @Necka,

Did you try keeping UseRpcMonoBehaviourCache to true but call "Refresh RPCs" in PhotonServerSettings under "RPCs"?

LaPanthera
2023-03-05 19:20:03

I had same issue and the matter was that in my network prefab i had missed scripts.

Back to top