Introduction

You want to create your own Realtime Multiplayer FPS?

Are you mad? Don't realise how incredibly complicated it is?!

Why is it so complicated?  I've written a single-player FPS before!

It's more complicated than a non-networked FPS for essentially one reason: so that when a player presses "move forward" on their keyboard, their view moves forward instantly, but also the server remains in control.

Because this needs to be instant, it means the client software must process the keypress itself, before it has had any time to confirm any details with the server (like "is there anything in the way?").  This means it has to essentially run the same game as the server.  However, this then causes two further problems: the client could potentially cheat, and also what happens if the client determines that one outcome happened (e.g. moves the player's avatar forwards), but the server (or another client) determines another (e.g. there's a wall in the way!)?

To avoid this kind of problem, the server is treated as authoritative.  This  means that it has final say on the state of the game, and if any client thinks differently, they had better get back in sync as quickly as possible, but still maintaining a seamless experience for the player.  So, the bulk of the additional code over-and-above a simple FPS is keeping clients and server in sync.

Is there any good news?

Yes!  SteveTech1 is designed exactly to solve all of these problems for you.  It still won't be that easy (as writing anything in 3D never is), but it will be a lot easier than it would be without it.

Ingredients

To make this example game, you will need the following:-
The good news is that it's all free.

Setting Up the Project

I'd recommend downloading the repository associated with this tutorial.  Even if you want to write all the code by hand, it will save you a bit of time when you can copy-and-paste some boilerplate code.

Once you have your favourite IDE open, create a new project and link it to the SteveTech1 code.  You will also need to link it to all the jars in the libs folder, since these are required for SteveTech1 to work.  These jars include libraries like jMonkeyEngine, which we use for the 3D, and Kryonet for the networking, as well as some more which will prove useful.

Once you've done that, you should have a clean project with no errors.  SteveTech1 should "just work", so please leave a comment if you have any problems.

In the next section, we'll be writing some actual code! 

Find Any Problems with this Tutorial?

The code, as with most well-maintained and non-abandoned open-source software, does change slowly over time as features are added and improved.  If SteveTech1 has changed which breaks any part of this tutorial, please let me know by leaving a comment below!


Comments

  1. The SteveTech1 link is no longer operable, ¨404 repository not found¨

    ReplyDelete
    Replies
    1. It's at https://github.com/SteveSmith16384/SteveTech1 . Where are you looking?

      Delete
    2. I've just seen where the links are wrong. Thanks for letting me know.

      Delete

Post a Comment