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.

[SOLVED] Received RPC...PhotonView does not exist!

2012-12-24 00:20:05

I instantiate a prefab over the network and get it to callback via an RPC after it's spawned. I get it to wait 5 secs before calling back just to be sure. Even though I can see the the local gameobject with ViewID 1000 in the scene I still get this error "Received RPC "rpcname" for viewID 1000 but this PhotonView does not exist!".

How can it not exist when I can see it in the scene :?

Like similar issues I'm only having this on second / third room I try to set up. First room after load always works flawlessly.


2012-12-25 06:51:53

I tried everything I could think of in my game and no matter what I do I get issues along these lines on the second room my players connect to. I was able to reproduce them in the marco-polo example. I've attached the code changes I made to the RandomMatchmaker.cs script below. My goal was to make an auto-matchmaker for a simple 2-player game. I altered marco-polo so when you create your own room it waits for 15secs or so and if another player doesn't join then it leaves the room and starts again looking for another room etc. To reproduce my error I start a copy on my phone and one on my laptop. After both players have joined the room I leave the room on the laptop (press the leave button I made) then wait for them to join again and I get this error on my laptop: "Received OnSerialization for view ID 2000. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined" followed by "MissingReferenceException: The object of type 'PhotonView' has been destroyed but you are still trying to access it."

Anything you can think of would be helpful :) cheers!

[code2=csharp]using UnityEngine; using System.Collections;

public class RandomMatchmaker : Photon.MonoBehaviour { private PhotonView myMonsterPv;


2012-12-31 06:45:05


Any ideas? perhaps it's a bug in photon or something I'm doing?

2012-12-31 10:41:49

do you correctly tear down previous rooms, that all PhotonNetworkViews are removed?

Means when you leave to the lobby you properly load into a different scene or DestroyImmediate every network prefab in the one you stay to reinstantiate them through Photons Instantiate when you enter the next room?

I ask because all network communication is limited and specific to the room you are in, when you leave the room all network stuff needs to go too.

2012-12-31 11:33:58

Thanks dreamora. I only use one scene but I can try the destroyImmediate thing. Do you think photon works better with a multi-scene setup? You can see how I leave a room in the code in the prev post. Pretty much just use PhotonNetwork.LeaveRoom(). I thought it auto cleans up everything itself.

2012-12-31 11:40:54

@Mishaps wrote:

Thanks dreamora. I only use one scene but I can try the destroyImmediate thing. Do you think photon works better with a multi-scene setup? You can see how I leave a room in the code in the prev post. Pretty much just use PhotonNetwork.LeaveRoom(). I thought it auto cleans up everything itself.

It works as good there as it does with a single scene. But with a single scene you are the one forced to do the maintenance and lifecycle handling, where as multiple scenes would move that to the scene cleanups. Most examples are also built around it as all Lite - Room based games normally use 2+ scenes. One for the matchmaking & lobby and one for the real game where the required assets are already cached for fast usage (if you did that in the lobby - matchmaking scene it would take much longer to load at no gain)

2012-12-31 12:05:29

Okay. Sounds like you're saying a 2 scene setup would work well for me as it would clean itself up better. Perhaps I should try that. I can't find anywhere in the documentation or examples that say I should do maintenance myself with a single scene? I'm not really sure what I should do for that anyway. Everything just says this will be taken care of for me. I bought the M2H guide and it had some code for doing "manual cleanup" which I tried but wasn't successful. I saw with TNet they seem to be expecting you to be using multiple scenes when you create a channel too. Perhaps that's the "done thing" for multiplayer.

2012-12-31 12:09:02

I reproduced it in the marco-polo example (see prev post). Essentially I only added a "leave room" button. I leave on one device then join again and it gets all those errors. Its a single-scene also so maybe if I tried breaking that up into two scene first it might fix it!

2013-01-01 23:00:41

Switching from single-scene to multi-scenes setup resolved all my issues. Thanks go to dreamora for the suggestion. :D

2013-01-02 14:15:48

Thanks for updating us and: cool you two could solve this! Happy new year :)

2013-01-08 18:40:37

I don't know if I would call this 'SOLVED', rather 'Worked Around'. I seem to be encountering the same issue but splitting into 2 scenes isn't really an option. Are there any documented steps for proper cleanup?

2013-01-08 19:08:37

If two rooms for a proper lobby - room split is no option its not hard to do either but you will have to fix your code to do its job properly for setup and teardown. There is no automatism here to just 'kick off'.

All you need to do is to ensure that all PhotonNetworkViews are gone when you get the OnDisconnectedFromPhoton called upon leaving the room. Once you received the OnJoinedRoom later on, you can use Photons Instantiate to instantiate all the networked objects correctly that are required in the room.

The reason you see the error otherwise is that the view and especially its view id and registration of the same are bound, exclusive and local to the room in which they were instantiated through Photon or first registered, so upon leaving a room they cease to be valid.

Potentially you could try to request new view ids upon joining the room, but I don't think this is an option for most games if not all anyway as you want a fresh, clean reset state, in which case destroying all 'non global manager' GameObjects and reinstantiating them again when needed is the straight forward and simple way.

2013-01-09 09:22:27

If you have problems with view IDs, you could try out the new version of PUN please. The new editor scripts should make sure every view in scene has a proper id. Find the download and discuss here: viewtopic.php?f=17&t=2333

The problems you have are maybe unrelated and not fixed by 1.18, though: There's still a known issue with instantiating objects in a scene before loading new scenes: Instantiated Game Objects are not cleaned from the server when you just load a new scene but they get cleared from the client. This means that the GOs are not in sync and one client might update objects that others already destroyed (by loading). Currently, a way to avoid this is to use PhotonNetwork.RemoveAllInstantiatedObjects(PhotonNetwork.player) to clean up your instantiated objects (on server) before you load a new scene. I will look into automatically cleaning up those objects when they get destroyed (no matter why).

About matchmaking: You should not use a room to match players, then get into another room to play. Aside from chatting while waiting, this is more or less random matchmaking and that's best done by the (master)server for you. Try to match randomly first and if that fails, create a room. If everyone does this, your rooms will fill up asap (depending on the number of players). ... references

2013-01-09 09:47:52

Mishaps: I know it's been a while since you posted your code. Now that Im more or less done with the PUN update, I tried it. Your room gets closed and when one player leaves, the other stays alone forever, waiting in a closed room for more players. Maybe I didn't get exactly how you produce the issue. I added code to open the room 5 seconds after one player left. Now leaving means that temporarily 2 games are open until the first player decides to leave and look for a game again.

I can't reproduce the issue in 1.18 with Marco Polo and your code. Can you?

2013-01-10 02:36:58

I'll check it out when I get the chance. How do I upgrade to 1.18? It still says 1.17 on the asset store.

2013-01-10 07:42:33

@Mishaps wrote:

I'll check it out when I get the chance. How do I upgrade to 1.18? It still says 1.17 on the asset store.

It has been released as a preview linked in a sticky thread here on the PUN board or viewtopic.php?f=17&t=2333

2013-01-10 22:07:38

cheers thanks for the link dreamora

2018-05-02 15:14:55

Hi All I have made multiplayer game,it works fine (all thigns sync).But when I change the scene to restart game with this code :
1- PhotonNetwork.LeaveRoom(); // on button click
void OnLeftRoom(){
then i create a new room add players to it(everything seems ok until now) but when i shift to gamescene the master clinet initialized all players but non master client does not although they are both on same level.The following messages from client side popup.

Received RPC for viewID 1001 but this PhotonView does not exist! Was remote PV. Owner called. By: 1 Maybe GO was destroyed but RPC not cleaned up.

Received OnSerialization for view ID 1001. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined.

Note: same messages pop up while doing PhotonNetwork.Disconnect() and leaveRoom().
Thanks in advance!

2018-05-02 15:17:33

players on clinet side did not instantiate also.

2018-05-03 12:31:24

A viewID 1001 should be a networked object by player 1.

Maybe loading the scene is causing this: When you join a room, you immediately get the custom properties and get the cached events (PN.Instantiate, e.g.). You need to make sure that you don't load a scene after you already instantiated something that should be in the room. Loading a scene will destroy game objects (unless you load additively or such).

Read "Timing for RPCs and Loading Levels" on this page:

If this doesn't help, you can run the SupportLogger to log the events/actions to the console and make sure everything happens in the sequence that you expect. What is different in the second attempt?!

2018-11-18 20:46:35

I had this problem and solved it by moving RPC call from Awake method to Start. Probably on Awake method call the object is not fully constructed and it can't receive the RPC call from himself if you have set the PhotonTargets.All

Back to top