Offline mode: Illegal view ID:-999

One of my objects (my localplayer) seems to have viewID -999. (everything else looks fine-ish). I'm trying to use Offline mode.... this is because I've submitted my game to OUYA and they insist on some offline capability.
This has worked before... I'm not sure what is happening.
The Illegal view error comes up when I try to do any RPC with it.
Thanks!
-Carmine
This has worked before... I'm not sure what is happening.
The Illegal view error comes up when I try to do any RPC with it.
Thanks!
-Carmine
0
Comments
You should join a room like you do when in online mode. Do you?
All of the PhotonNetwork.instantiate works (my bad guys etc)... and it seems all of the other objects made have viewid's (that look ok). They are normally 1001, 1002 etc. It seemed they were lower numbers (1, 2, 3)
The PhotonView ID is a composed number of playerId*1000 + objectInstance. Both variables start with 1 in online mode.
I'm lost: Can you still repro the -999 viewID? Is there any way we can (likely) reproduce it?
Is there some manual way for me to fix/get that ID?
What is your workflow? Maybe our order to call callbacks is might be wrong when in offline mode.
In which situation/callback do you instantiate the object that has the bad ID?
- Join room comes back successful
- I set a boolean/flag/etc. that the join worked...
- My main loop sees the flag is set and then starts creating things... (in other words I'm NOT creating in OnJoin.. i'm just setting a flag that we're good to go)..
- It's always -999
Is there something I should be looking for?
When do you set offline mode in the workflow described above? Can you add this?
In the moment you set offlineMode = true, we call OnConnectedToPhoton and then the player ID will be changed to 1.
It seems you create the object in question before this is done (while being player ID -1).
Can I take a look at your project? Msg me or let me know via mail: [email protected].
- I have a main menu (no network instantiate has been called).
- Player can go to "options" and choose "offline mode" (still haven't network instantiated anything)
- Player can choose their ship, color, etc. (nothing being done on network still)
- Player hits "launch" and it calls Join room
- If join room works.. it sets a boolean flag...
- If my loop sees the flag... it calls Network.Instantiate for the player's ship. The player's ship is a Resource that has a photonview attached.
Is there a way for me to print out the current playerid?
My project is huge and my baby and I love you guys, but I don't want to send it to anyone.
I will try to reproduce this as next task and see if I can fix something for next release.
You can access the player's ID via PhotonNetwork.player.ID.
I just noticed I didn't ask: Which PUN version do you use??
> My project is huge and my baby and I love you guys, but I don't want to send it to anyone.
Hehe. That's fine. Just asking!
1.2 would be really old and I'm sure it has several issues with the offline mode.
The current version is 1.22.3 (the second number counts as twentytwo).
As far as I could see, the current version also has a few kinks with the offline mode. E.g. setting offlineMode = true will trigger OnConnectedToPhoton but nothing else and an additional call to ConnectUsingSettings will override offlineMode and go online.
I changed this a bit here but I still have no clue why your view ID is -999.
In best case, you could log out the callstack in the PhotonView.viewID setter or in Awake.
I use a workaround to set the IDs of PhotonViews, so no Awake can break it, so the viewID setter might not be called.
Or you print out a log entry after PhotonNetwork.Instantiate() when the instantiated PhotonView ID is negative. This also gives you the location where the PV is instantiated exactly.
Hello,
- I just downloaded the most recent PUN and I still have the error.
- If this helps.. when I try to destroy objects, I get an error: "Failed to Destroy objects of playerId: -1"
- I don't understand your answer about the Awake, viewID, etc. If you could give me some code to cut and paste to fix this that would be great.
In order for my game to be allowed in the OUYA store, it needs to work offline. So now when I submit my next update to my game, it will get rejected
I can't produce the error and so I don't understand how you get the bad ID in the first place.
To find the place where the player ID is still -1 while instantiating something, we need some debug output. I got a commented-out piece in Instantiate, just above the call to AllocateViewID(). Make it:
[code2=csharp]Debug.Log("Instantiate prefabName: " + prefabName + " player.ID: " + player.ID);
viewIDs = AllocateViewID(player.ID);[/code2]
Also change the logLevel to PhotonLogLevel.Full please.
Then I need the full log. To see where/when this happens in relation to the rest.
As quick fix, you could also modify AllocateViewID() to use the ID 1 if in offlineMode and ID is still -1.
Did you solve this somehow?
I am thinking about refactoring the offline mode up to the point where all the Demos will work with it immediately. This might break it in a different way for you though. In the end, I think it makes sense, no matter if it breaks your status quo.
What do you think?
Enjoy your vacation, too! Just wanted to remind you to give me a nudge when you're ready
So it's definitely player.id = -1 when it's calling AllocateView.
I tried forcing it to be 1 if it's -1 and in offline mode... the photonview attached to my object is showing:
Owner: [1] <no PhotonPlayerFound>
View ID: 1001
Any ideas?
-Carmine
Forcing it to 1 means you can't find the player later on.
Does your PhotonNetwork.player.ID ever turn 1?
Again I just have another small step forward, adding more logging. Please see what the offlinemode value is and have a look at the callstack. Maybe this happens due to unexpected order of execution for some of your scripts?
Debug.Log("Instantiate prefabName: " + prefabName + " player.ID: " + player.ID + " offlineMode: " + PhotonNetwork.offlineMode );
Btw: When you set offlinemode, we will call OnConnectedToPhoton first, then set the local player's ID via ChangeLocalID(1). So if you instantiate anything in OnConnectedToPhoton the -1 is no surprise. Better also call CreateRoom and do instantiation in OnCreatedRoom or OnJoinedRoom.
Most likely I am repeating myself about the last bit
The value was definitely true (I did that in my testing).
Question.. when I set offline mode, do I need to call disconnect?
In online (normal) mode:
- Player.ID is always starting as -1
- When I join a room, it changes to 1
Now... in offline mode:
- Player.ID starts as -1
- When I join a room, it's still -1
-Carmine
I just verified this in PUN 1.23.2 (actually, it's close to being released as 1.24).
Neither CreateRoom nor JoinRoom will re-set this to -1 in offline mode.
http://u3d.as/2ey
The new PUN fixed it!
Thanks for letting me know.