Game Development Community

Do I need real-time networking for this?

by Nicolai Dutka · in Torque Game Builder · 04/17/2008 (9:40 am) · 7 replies

I have a top-down shooter similar to 1942 on NES or Space Invaders for Atari. I have 1 player or 2 player
(simultaneous) modes. I'm getting ready to plan the networking abilities so both players can fly around and shoot enemies at the same time.

Do I need to look into getting something like RakNet, or is there a possible solution that would work using the current networking abilities in TGB 1.7?

#1
04/17/2008 (10:53 am)
I'm not discussing the value of event-based networking models, but Mr. Zepp had plenty to say in this thread.

www.garagegames.com/mg/forums/result.thread.php?qt=71987
#2
04/17/2008 (10:55 am)
Hm RakNet looks interesting. Im sure noone would complain if you were able to integrate it with TGB '-)

But TGB has event based networking that you can really use to accomplish whatever you need. The complexity is how to ghost objects on the clients - how to handle corrections - implementing client-side prediction - stuff like that.

I would be surprised if RakNet implements those parts of networking - but it might - a lot of that could be specific to your game, so just work you have to do.
#3
04/17/2008 (10:55 am)
Actually, that post is what led me to posting here. I wanted to know if I should use RakNet or can I accomplish my goals with the built-in, turn-based networking...
#4
04/17/2008 (11:00 am)
Well as Stephen said in that thread, TGB's networking is not "turn-based", it is event-based. I'd recommend digging in to the TGB networking. It can definitely do what you want -- probably not totally in script without C++ code -- but integrating a new library seems ( to me ) like more work.
#5
04/17/2008 (11:07 am)
Can we please get the marketing material changed to remove "turn-based"?
#6
04/17/2008 (11:09 am)
Let's scope out your project more completely so we can make an educated strategy :)

--How many objects do you expect to network? Obviously, the objects the player controls, and probably the enemies, and the bullets--but depending on your game expectations, that could be 10 objects, or 1,000.

--are your objects deterministic in their physics? In other words, do your bullets and enemies fly paths that depend on the simulation itself, or can you reasonably base all of the object's paths and effects on a combination of time passing and network events arriving?

Example:

--If during a level, a wave of creatures always follows the exact same path regardless of what the player does, then you don't need to network those objects at all--all you need to network is the time at which the level should start. From there, each client simulation can deterministically duplicate the locations of each of the enemies with no networking at all.

--you can do the same thing with bullets--instead of trying to network each and every bullet, take a half step back and network "startFiring Player1" and "stopFiring Player1"--then, each client can simply create bullets locally, and approach synchronization relatively realistically.

--from there, you can start adding in corrections to the simulation (otherwise known as synchronization)--when an enemy is destroyed on player A's machine, send an event to the other players in the simulation that destroys the enemy. Once you've identified the key objects that actually do need to be updated and maintain tight synchronization, you can start expanding this concept of corrections with things like "Player1Ship PositionUpdate 12.6 32.2", and use interpolation on the receiver's side to re-synchronize if needed.

Finally, and this is something that can be hard to recognize: No network simulation, ever, is completely synchronized--it's impossible, because there is no such thing as 0 latency (data always takes at least some time to transfer from one computer to another). With that truism in mind, you now need to decide just how synchronized you must be for reasonable game play...and that will drive your implementation decisions.
#7
04/17/2008 (11:18 am)
I only need to network the 2 players and their controls, one boss enemy per level, and the spawn points.

Here is a chunk of one of my levels:
while(%loop<145)
    {
      %spawn1=getRandomSpawner();
      addEvent(schedule(%time,0,spawnEnemies,%spawn1,1,%speed));
      if(isObject($player1) && isObject($player2))
      {
        %spawn2=getRandomSpawner();
        while(%spawn1==%spawn2)
        {
          %spawn2=getRandomSpawner();
        }
        addEvent(schedule(%time,0,spawnEnemies,%spawn2,1,%speed));
      }
      %time+=600;
      %loop++;
    }

    addEvent(schedule(24000,0,spawnEnemies,spawnPath4,7,%speed));
    addEvent(schedule(25500,0,spawnEnemies,spawnPath3,7,%speed));
    addEvent(schedule(27000,0,spawnEnemies,spawnPath2,7,%speed));
    addEvent(schedule(28500,0,spawnEnemies,spawnPath1,7,%speed));

So, all the events will be the same no matter what except for one part: getRandomSpawn();
Obviously, if spawn point 1 spawns an enemy on client one, I don't want spawn point 3 spawning the enemy on client two, so the server should tell the clients which spawn point to use.