Author Topic: Trouble with switching channels on persistent static network objects  (Read 2161 times)

Ninja

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 21
    • View Profile
Hello,

I have a chat manager object for handling all chat related things. Players can send multiple chat message types (channel, server (broadcast), group and whisper). The chat manager has DontDestroyOnLoad so it persists through scenes. My players can change scenes, which also changes what channel they are in (so they do not see the other players on other maps). Channel chat stops working because I can't seem to change the chat manager's channel ID correctly.

I've tried calling TNObject.TransferToChannel(channelID), but it doesn't seem to do anything. The Channel value on the object never changes. If I try to set the channelID directly, the Channel value does change, but then I get a warning about RFCs not being sent because the object wasn't created correctly ([TNet] Trying to execute RFC #1 on TNObject #1 before it has been created.)

I could just stick the chat manager into every scene instead of having it persist through loading, but that just seems silly when theres a TransferToChannel method. I must just be doing something wrong.

I hope that makes sense, any help would be appreciated!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trouble with switching channels on persistent static network objects
« Reply #1 on: June 28, 2016, 09:09:48 AM »
Objects must always belong to channels. For chat, join a secondary channel that will have the chat object inside it (you can be in more than one channel at the same time). There is no need to transfer the chat object as you should remain in the chat's channel throughout your gameplay.

Transferring objects only works for dynamically created objects. Static objects (ones present in the scene on load) can't be transferred.

Ninja

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Trouble with switching channels on persistent static network objects
« Reply #2 on: June 28, 2016, 04:18:42 PM »
Ah ok, that makes sense. Thanks!