Author Topic: Channel Transfer  (Read 1732 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Channel Transfer
« on: October 16, 2016, 08:13:19 AM »
My player seems to be getting destroyed while switching channels.  Walking around a streaming map he disappears.  While debugging OnDestroy() I can see the player still in channel 60 and 64. Of course this is after he is destroyed.



It took awhile to trace why he was getting destroyed. If I remove the TNObject, he won't be destroyed. I'm only testing on one device and this still happens.  I am thinking he is getting destroyed on the transfer, but he is not making the transition to the new channel.

I am using the ExamplePlayerAvatar.cs script for channel transfer.

Thoughts?

Edit:

Playing with the multiple channel example scene. If you spawn in two cars. The second car has priority. Which means the second will take control of the camera and won't be destroyed while switching channels. In my case, perhaps it doesn't know.  I can't seem to find anything yet that lets TNet know not to destroy the object while transferring channels.
« Last Edit: October 16, 2016, 09:40:51 PM by voncarp »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Channel Transfer
« Reply #1 on: October 17, 2016, 10:23:32 PM »
I'm guessing you have nested TNObjects on your player. Nested object ends up with ID of 0. I recently fixed this issue in the Pro version of TNet, so you will find it fixed in the next update onwards. Modify TNObject's OnLeaveChannel like so:
  1.         void OnLeaveChannel (int channelID)
  2.         {
  3.                 if (mParent == null && this.channelID == channelID && uid > 32767) // <-- this check right here
  4.                         Object.Destroy(gameObject);
  5.         }