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

Comments

  • Hm, this could be related to being player -1 while you are not in a (fake/offline or online) room.
    You should join a room like you do when in online mode. Do you?
  • Everything is exactly the same... The only difference is setting it to offline mode.

    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)
  • Hmm, maybe you get player number 0 in offline mode, instead of 1. I'll have to look that up.
    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?
  • It's happening every single time I run my game now... I never noticed this happening before... maybe this got in in some recent update you've made?

    Is there some manual way for me to fix/get that ID?
  • No, there is no built-in way to change IDs.
    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?
  • - I call Join room
    - 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?
  • I am still not sure how the object with -999 is being created and or when.
    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].
  • Tobias wrote:
    I am still not sure how the object with -999 is being created and or when.
    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.
  • Sorry, I overlooked your reply yesterday!
    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!
  • I think 1.2?
  • You can check via PhotonNetwork.versionPUN string.

    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.
  • Tobias wrote:
    Y

    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 need you to help me help you.
    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.
  • To pick this up again: I added you in Skype but for whatever reason, we're never online at the same time. Also: I didn't read anything from you since a few days.
    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?
  • Hey! I'm on vacation for a week or so (it's my birthday today)... I'll pick this back up with you next week...
  • Happy Birthday!
    Enjoy your vacation, too! Just wanted to remind you to give me a nudge when you're ready :)
  • Tobias wrote:
    I need you to help me help you.
    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.

    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
  • I still want to know why the heck your player is -1 when you switched to offline mode. This should not be possible.
    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 :)
  • Tobias wrote:
    I still want to know why the heck your player is -1 when you switched to offline mode. This should not be possible.
    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?
  • When does PhotonNetwork set player ID to 1?

    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
  • When you set offlineMode = true, it should switch from -1 to 1 immediately.
    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.
  • When is that release happening? Because it's definitely not happening :(
  • I just submitted the update to 1.24 to the Asset Store.
    http://u3d.as/2ey
  • Tobias wrote:
    I just submitted the update to 1.24 to the Asset Store.
    http://u3d.as/2ey

    The new PUN fixed it!
  • How cool is that?! :)
    Thanks for letting me know.
Sign In or Register to comment.