Author Topic: Simple TNet Question- Authoritative Server  (Read 1921 times)

Kalagaraz

  • Guest
Simple TNet Question- Authoritative Server
« on: July 15, 2013, 11:53:20 AM »
What is best way to implement an authoritative server using TNet/Unity? I ask not only in form of efficiency/security but code organization and ease of programming as well.

My current thinking is to have 2 different projects for game. Client project and Server project. That way server code is never distributed to the players.

But should I create the server project as a Unity Project and run without graphics, or should I just make a stand-alone server in just pure C#?

Obviously if I do it in Unity programming will be a lot simpler, however my concern is that it may not run very efficiently?

Any thoughts?

Thanks,
Kalagaraz

Kalagaraz

  • Guest
Re: Simple TNet Question- Authoritative Server
« Reply #1 on: July 15, 2013, 01:00:43 PM »
Little Update:

Well I just learned that Unity supports preprocessor directives, so really no need to separate projects now.

For anyone that is interested if you don't want your server code compiled and distributed to players in the client just do something like:

Quote
#if SERVER
void UpdateAILogic()
{
 //BLAH!
}
#endif


then add the SERVER define to your build settings if your compiling for your server application. I'd also have some kind of message pop up when starting application that its a server build too just to make sure you don't accidentally distribute it :).

Thanks,
Kalagaraz
« Last Edit: July 15, 2013, 01:08:11 PM by Kalagaraz »