3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: Dedicated Server For Multiplayer: Some Thoughts  (Read 410 times)

« on: July 03, 2013, 02:31:09 PM »
ok... here's the thinking on this...

1 - In your game, you're aboard a large vessel... a submarine... a star ship... or in a big building...

2 - There are 3 or 4 players running around... either with weapons trying to shoot each other, or with the ability to control the vessel that they are aboard, or reach a goal in the building they are in...


How would you make something like this... how would you plan the thing out before you start developing the logic and the artwork... what are the things that you have to take into consideration...

Well... first, i would think that modeling the entire vessel, building, or level would be outta the question... especially if there are several things that need to be done at different parts of the ship, building, or level... and if the level has a high degree of detail...   

In this case i think that a separate model might be appropriate for each "area of activity"... as well as a separate .3dr project file, just so that things (logic, 3drad object linkings, model geometry) would be kept simple and at a minimum...

So... in short... s hip could have a control room as a level ( model and .3dr), a Combat Info Area as another level (model and .3dr)... and possibly other areas, also as separate model and .3dr projects... and the game would allow the players to go between different parts of the ship during gameplay...

This is where the idea of a DEDICATED SERVER CAME UP...

If the server was controlled by one of the players, then the entire game would pause when that player changed levels...  not good...

also..

If the ship were in motion, it would also stop when this player changed levels...

finally...

Since I do all the physics stuff on the server and only have the user inputs come from the clients, i need the server to be running all the time...

OK... all this is not as complicated as it sounds...

If you wanna try it, load up the NetBall Arena demo and remove the camera object... select a non visual object and save the project... reload it and exit RAD... Compile it and run it... when it comes up, minimize it and open 3DRAD and run the NetBall Arena Client.... 

you'll see that you can now log onto the running server and play the game... 

does this interest anyone planning a multiplayer game...  (you're gonna need to have some knowledge of scripting and the Net Global Array)

**edited **

actually, the stuff here is applicable to single player as well as multiplayer games... if anyone remembers the original UnReal Tournament, regardless of whether you were playing single player or multiplayer, a server was always running...  the same applies to the Torque Game Engine...

actually, it makes a lot of sense dividing your game into GAME LOGIC and CLIENT LOGIC parts... it'll make any  game easier to develop...


--Mike
« Last Edit: July 04, 2013, 09:30:45 AM by Mike Hense »
« Reply #1 on: July 05, 2013, 10:09:42 PM »
PART II

Why make a Dedicated Server 3DRAD Mulitplayer Game instead of the usual 3DRAD Multiplayer where the server and the first player are part of the same game you may ask... and then again, some may not ask or even be interested...

for those who are interested:

1 - The thought process is simpler since, at any one time you're either making the Server, or making the Client... The Game Is On The Server... The Client Input is on the Client... 

2 - The Server, once started treats all players equally... noone has a real advantage since everyone is a client and the action is happening on the remote Server...

3 - Since the Clients only take user input, send it up to the Server, then echos (ghosts) what is going on on the server via the synched skinmeshes... you don't need to have duplicate character objects on both the Client and the Server...



THINGS MOST 3DRAD MULTIPLAYER DEVS FORGET, OR SIMPLY AREN'T AWARE OF:

1 - Version 7.xx has Network Aware Objects which make the entire process of making a 3DRAD Multiplayer Game almost script free  by allowing objects to automatically synchronize across the network  by the use of NetworkIDs and Player Numbers...

2 - The NetworkIDs are sequential, they start from 1, and everything that is net aware has to have one... for example, if you have a character object on the server, you will use up 5 Network IDs (1,2 for the left/right controls... 3,4 for the fwd/back... 5 for the run fast control)... the next one available will be 6 which should be assigned to the skinmesh (andro) representing the character...  and so on, and so on...  the next character group will start from the next available NetworkID...

3 -  The first player is usually player#0... but if you use the Dedicated Server methodology, there will be no player#0... player#1 will be the first player... easier to keep track of...

THE PROCESS IS MUCH SIMPLER THAN YOU THINK...

1 - Make your game the way you normally would...

2 - Remove the cameras and set the NetIDs and Player Numbers...

3 - Compiler the server and run it...

4 - Load the Server version into the editor, rename it and save it as the new client app, replace the character objects (or car objects) with event-on-input objects and set the appropriate NetIDs and Player Numbers...

5 - run it from the editor to check...

We'll try a simple walkaround Dedicated Server Multiplayer Tommorrow...

--Mike   






« Last Edit: July 06, 2013, 05:28:53 AM by Mike Hense »
« Reply #2 on: July 06, 2013, 06:06:35 AM »
PART III

Making A Simple Dedicated Server And Client Multiplayer Game that you can run and test on a single machine...

STEP 1 - Make the game as if your were making a single player game... not really a game of any kind, this project is going to be a simple first person walkaround, so there's no complex logic that'll require scripting... all of the game will be able to be implemented with 3DRAD objects... 

All we'll need is a terrain and a user controlled walker...  you'll also need to add the skybox, a gravity object, and a sunlight object... (or, you can use the premade Starter Project and First Person Character resources to get your project off to a quick start...

When you have the First Person Character walking around the terrain properly, save it as MPGameTest1.3dr... 


STEP 2  THE SERVER - Next, we'll make some changes that'll transform our simple game into a 3DRAD multiplayer Server...  First, we'll need  to add a Script object (Don't Be Scared! :) ) to get the server part running and connected to the internet... copy and paste the following simple script into it...

Code: [Select]
//This script enables multiplayer mode for
//a project designed to run on the server.

bool NetworkActive = false;
void Main()
{
   if (iInitializing())
   {
      //Activate the server network system.
      if (iNetServerStart("DedicatedServerTest1","Server",25857,987654321,100000))
      {
         NetworkActive = true;
      }
   }
   if (iDeinitializing())
   {
      //De-activate the client network system.
      if (NetworkActive)
      {
         iNetStop();
         NetworkActive = false;
      }
   }
}

Save your project now as DedicatedServerTest1.3dr... 


STEP 3 - Next we need to set up the 3DRAD Net Aware objects in the Server so that they will "sych" with the objects on the Client (which we still need to make)...

This is really simple, but can be a lil confusing... There are 2 key concepts that we need to understand... NETWORK IDs  and  PLAYER NUMBERs...

NETWORK IDs are numbers assigned only to the 3DRAD net aware objects to make them unique, so the system can sync each one on the Server with the object that has the same NETWORK ID on the client...

The Character object is a network aware object that needs to have these values set... near the bottom  of the property dialog box, find the Network IDs For Controls settings boxes and set 3,4 for left/right  and 1,2 for fwd/back and 5 for run mode... You've now used NETWORK IDs 1 thru 5...

The next net aware object that'll need a NETWORK ID is the Andro Skinmesh... open the dialog box and set the NETWORK ID to the next available number (6)...

Save your project... (Note... from this point on, if you run the project,  you won't be able to move your character since it is now set to be controlled from the client... which we'll be making now)...


STEP 4  THE CLIENT - Next we'll make some changes in the Server To Transform it into the Client... To Avoid overwriting the Server we just put together, immediately save the project as DedicatedClient.3dr

Now we need to remove the Character object and replace it with an EventOnInput object... remember, this is the Client we are working on now, and the Client side is only for getting user input to the Server...  so we only need an EventOnInput  object FOR EACH KEY CONTROL WE SET NETWORK IDs FOR when we were working on the SERVER...

The first EventOnInput will be set for PLAYER#1, and For NETWORKID 1, and will be for the FWD CONTROL input (the UP KEY)...

YOU'LL NEED ONE EOI FOR EACH CONTROL THERE IS A NETWORK ID FOR...  so, add one for each and set the NETWORKID as required, the KEY hit as required, and the PLAYER# TO 1...


STEP 5 - Finally, add  a SCRIPT object then copy and paste the client script below... This is to get the Client Networking Started...

Code: [Select]
//This script enables multiplayer mode for
//a project designed to run on a client PC.

bool NetworkActive = false;
void Main()
{
   if (iInitializing())
   {

      iCommandContinue ("cmd.exe /c start /min .\\3drad_res\\compiledproject\\DedicatedServerTest1\\DedicatedServerTest1.exe");
      //Activate the client network system.
      if (iNetClientStart("","Client",987654321,100000,"Connect",-1,0))
      {
         NetworkActive = true;
      }
   }
   if (iDeinitializing())
   {
      //De-activate the client network system.
      if (NetworkActive)
      {
         iNetStop();
         NetworkActive = false;
      }
   }
}


An important thing to note here is that this script will also automatically start the Server each time the client is run...  (more on this in a sec)...


STEP 6 - Save the Server and Compile It In The Windowed Mode and Make Sure the Name Is The Same As The Name In The Client Script... After you Compile It, change the name of the folder to delete numbers at the end, and again, make sure the path in the Client script is the same so the Client  iCommand will find it...


OK... That's It... You can Go Back To the Editor and Run The Client From there... it'll magically start the server and put you in the search dialog...  You should see the Server Running in the task bar below...

Note: you can leave the Server running if you wanna make small changes to the Client, but you'll have to comment the iCommand line in the script so that it doesn't open up a new server each time you run the client...

Now that you see the basics of how this works, you can go and add more players and add more features (you'll need to modify both Server and Client)...

Good Luck...

--Mike

« Last Edit: July 06, 2013, 06:59:57 AM by Mike Hense »
« Reply #3 on: June 21, 2014, 09:39:30 AM »
It is possible to use a script on standard server to selected, and the standard client for the game with a dedicated server?
On a dedicated server whole game AI, all game objects and management, clients Scinmeshs players and button control. I understand the idea?
Not talking about the + and -
« Reply #4 on: June 21, 2014, 09:56:54 AM »
i'm abandoning the dedicated server framework in favor of a more 3DRAD friendly (similar to the NetBall Arena Multiplayer Demo) structure...

although the concept works... in practice the workflow becomes a lil too involved, and i find that, in effect, you wind up having to make two games...  while working the community project i came to the conclusion that making the game once is a lot easier than making the game twice as the dedicated server framework necessitates...

the benefits of the dedicated server are not enough to justify it over the more streamlined workflow of the traditional method of having the server app also be under player control...   

i'll have something up in a few days...


--Mike
« Last Edit: June 22, 2014, 07:32:58 AM by Mike Hense »
Pages: [1]