Author Topic: RFC messages fail to deliver after scene change issue  (Read 2668 times)

damocles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
RFC messages fail to deliver after scene change issue
« on: December 18, 2013, 11:15:45 AM »
I've hit a wall trying to figure my current problem out.  I want my game to have a screen where it's searching for games, then after a valid game is found, everyone connects and the game changes to the actual game scene.

During the menu with the game searching, the connections are made and all events send as normal.  After the scene changes, no RFCs get through in either direction (it's a 1v1 game), but no errors are output either.

I've made sure my TNet objects are marked DontDestroyOnLoad, and sure enough they stay after scene change.  I'm using Application.LoadLevel to change scene, so nothing out of the ordinary there.

I'm confused as to why the RFCs would stop working after a scene change.  Before the change, I can send RFCs reliably, but afterwards nothing goes through.  There's no disconnection messages, or error messages from the attempted RFCs.

Anyone have any idea why this might be?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC messages fail to deliver after scene change issue
« Reply #1 on: December 18, 2013, 12:55:48 PM »
Any particular reason you're not using TNManager.LoadLevel instead? Other than that off the top of my head I can't think of anything that would cause them to stop working. Is your TNManager still present alongside your persistent TNObjects?

damocles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: RFC messages fail to deliver after scene change issue
« Reply #2 on: December 18, 2013, 03:57:46 PM »
Yep, I definitely have all the TNManager/TNObjects and related other objects in the newly loaded scene, so that side is fine.

I just tried TNManager.LoadLevel and the problem persists, but an error is showing up now:

Exception has been thrown by the target of an invocation. (TNObject.OnNetworkPlayerLeave)

This normally means a reflection invocation can't find the method, or the method has bombed.  The problem is, I haven't overridden this method yet, so it should be using the TNet default.  I'm also unsure as to why a player leave event is triggering - both players are still active and connected (or they should be).

So I looked into the Tnet code, and OnNetworkPlayerLeave is:
  1. if (mOwner == p.id) mOwner = TNManager.hostID;
and it turns out p is null.  Somehow the method is being sent a disconnection event for a null player.  Do you have any idea what might cause this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC messages fail to deliver after scene change issue
« Reply #3 on: December 18, 2013, 05:32:57 PM »
What's the full call stack?

damocles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: RFC messages fail to deliver after scene change issue
« Reply #4 on: December 19, 2013, 04:19:46 AM »
Ah, I've found the culprit.  I had a TNManager object in the scene that gets loaded.  I thought I had disabled it (I use it for offline testing) but it seems I had not.  I guess TNet doesn't respond well to having two managers running.

Sorry to waste your time over my silly mistake.