![]() The server then listens to connect and disconnect requests and assigns a player number to each connected player. Luckily Unity lets you do this in about three lines of code. So the first thing you need is a lobby that allows you to create a server or join an existing one. The major advantage of this is that all clients run the exact same code and if the game functions correctly in single player then you’re confident it will work in multiplayer, which makes testing a lot easier. Conceptually we have a separate client and server running in the same process, and all communication is through the network, even if it’s a single player game or your client is the server. Requiring a dedicated server for LAN play just seems messy and requires building and running two executables, which is a pain. This is as opposed to a dedicated server where you have a separate server process that all player clients connect to. My preferred setup uses an authoritative server (the clients send inputs, and the server processes them and sends back the results) but the server is also a client so can play the game. The second is to use Remote Procedure Calls (RPCs) which allow one instance of the game to call a function on another instance (to signal events, e.g. The first is to mark variables on objects as being synchronised, so that they’re automatically kept up to date across clients (e.g. ![]() There are two methods in Unity of networking your game. It didn’t take long to run into the first problem with the built-in networking solution, but more about that later. ![]() My current game-making interest is for multiplayer LAN games (if you can’t find the perfect game, make your own!), so my first project was investigating the networking support and making a basic lobby. However, my next thought: this is so far removed from normal programming, how do I actually, you know, “make a game”? This is the bit I need to get my head around next, learning the proper ways to translate my normal C++ skills into the Unity paradigm. Creating it mainly involves dragging a few things around in the interface, and writing a few lines of code. One of the basic tutorials is a vertical scrolling shooter, and within an hour or two you have 3D models, sounds, particles and some basic enemy waves. My very first thought, going through one of the tutorials, was “this feels like cheating”. Everyone I know (for “everyone” = “programmers”, anyway) seems to be trying out Unity and I’d heard much praise about how easy it is for rapid prototyping. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |