Author Topic: A few questions.  (Read 4553 times)

Pinden

  • Guest
A few questions.
« on: November 19, 2013, 09:53:17 PM »
Hey everyone!

I am considering using TNet for a project, because it seems really well suited for what i need.
In short, its mainly a single-player game in which the user can "open" up a server an allow a few friends to join it (the ongoing game). When they join they will get sent the world info from the host and from there on it will work like most other multiplayer games.

As i understand it then TNet can be used just as well in a single player "mode" so it will just "send" packages as if i was the only player on the server. This design seems be great for my game and will really decrease the development time.

My question is though around the creation of player hosted games and letting players join it.

How does all that work in TNet? Is there an easy way for a player to host a game and then let people see/join it in some type of online lobby?

A short answer would be great, a code snippet of how it would work would be simply awesome!

Thanks!  :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: A few questions.
« Reply #1 on: November 19, 2013, 09:57:56 PM »
If you don't start a server and don't connect to anything, then call calls to TNet such as tno.Send(...) will simply execute local functions -- as if you were connected but happen to be in the channel by yourself.

If you do start a server (TNServerInstance.Start, or stand-alone executable that comes with TNet), you can then connect to it and join a channel. At this point you are effectively playing multiplayer, even if you happen to be there by yourself. Other players can join you, provided they can reach your server.

It's a good idea to have an external lobby server and have your game servrs register with it as explained here: http://www.tasharen.com/forum/index.php?topic=6538.0

Pinden

  • Guest
Re: A few questions.
« Reply #2 on: November 19, 2013, 10:05:10 PM »
If you don't start a server and don't connect to anything, then call calls to TNet such as tno.Send(...) will simply execute local functions -- as if you were connected but happen to be in the channel by yourself.

If you do start a server (TNServerInstance.Start, or stand-alone executable that comes with TNet), you can then connect to it and join a channel. At this point you are effectively playing multiplayer, even if you happen to be there by yourself. Other players can join you, provided they can reach your server.

It's a good idea to have an external lobby server and have your game servrs register with it as explained here: http://www.tasharen.com/forum/index.php?topic=6538.0

Thanks a lot for the quick answer. So the TNServer i need to start on a server, is that an .exe that comes with TNet or some Unity instance i need to setup and run on the server?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: A few questions.
« Reply #3 on: November 19, 2013, 10:18:14 PM »
Tiny executable (~50 kb). You can also launch a server from within your Unity game (TNServerInstance.Start).

Pinden

  • Guest
Re: A few questions.
« Reply #4 on: November 19, 2013, 10:23:44 PM »
Thanks a lot! Seems like it would fit my project perfectly!