Author Topic: Confused by channels  (Read 4628 times)

Suvu

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Confused by channels
« on: February 16, 2013, 11:57:03 AM »
Hey all,
I've run though the example scenes, documentation and 'getting started' page, but i'm still having a bit of trouble understanding how to get things setup or how things are SUPPOSED to be set up.

I've been working on a multiplayer game for a while but using Unity's built-in networking.
The way I started a server/connected to a game was pretty simple :

To create a server
  • Initialize server
  • OnServerInitialized - Load first level
  • OnPlayerConnected - Send netLoadLevel RPC with current levelName

To connect to a server
  • Connect(serverIP)
  • Waits for server to send current level
  • Loads level and receives current gameState

But now switching to TNet, I find it confusing....
I can start a server, and connect to it, just like the way it's shown in the ExampleMenu.
But then the channels throw me off. I previously had the server 'tell' newly joined clients which level to load, but with TNet, when you join a channel you need to specify the level to load. And no communication can take place before you join a channel.

I think i'm getting completley the wrong idea here >< How does the client know which level to load (the level the server is currently on)

krissebesta

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Confused by channels
« Reply #1 on: February 16, 2013, 12:24:57 PM »
Hey Sevu, the first client that hosts the game can call TNManager.JoinChannel() and specify the level to load for all other clients to load when they join (they can leave the level parameter a blank string, "").

See this thread for more details.

http://www.tasharen.com/forum/index.php?topic=2925.0

Cheers! - Kris


Suvu

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Confused by channels
« Reply #2 on: February 17, 2013, 08:17:15 AM »
Ahhh ok, thanks for that Kris!
I should have tried that before posting ><
That makes much more sense now, I also read a post from Arenmook over on the Unity forums where he likened it to IRC.

Thanks again for the help!

krissebesta

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Confused by channels
« Reply #3 on: February 17, 2013, 07:44:59 PM »
@Suvu: I did some additional research this morning and noted that the channel list is, in fact, stored in the TNGameServer class.

Also, I have re-worked the examples that come with TNet to use channels.  If you want I can post the code.  Just let me know if you want it.

Cheers! - Kris

Suvu

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Confused by channels
« Reply #4 on: February 18, 2013, 09:30:55 AM »
Hey Kris, I think i've got my head around it now thanks :) but it might be worth posting an example for anyone else who has the same problem.
I still have a couple of other questions but i'll start a new thread about them.

Cheers!