Godot Multiplayer - Tips & Hints | Godot Dedicated Server #19

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this godot multiplayer video i want to take the time to give you a couple of last hints and tips and share with you some considerations that are going to be important to take your multiplayer experience further beyond where these tutorials have taken it so far let's get into it so the first topic i want to talk about is to make sure that we protect our game a little bit further right here you'll see a line of code that is pretty much checking whether the remote function call is done by the peer id one or otherwise the server you want to make sure that every single remote function on your client on the server interface is starting with this line of code otherwise it could be that a individual were to change some of its source files instead of sending signals to only the server like we do with rpc id1 it's sending out signals to all the clients maybe crashing clients or letting clients things to believe that are actually not true so we want to make sure in this authoritative environment that all the remote function calls that go to a client are coming from the server and we can verify that with that line of code so do make sure you add those to the various remote function on your client the second thing i want to talk about it's not so much of a hint or a tip but it's more of a best practice that i strongly advise you to follow when you go on a discord or reddit and you talk about multiplayer you very often hear the statement and i've alluded to it a couple of times in this multiplayer series never trust the client when we switched our coalition detection system in the tutorial series from the client to the server we did so because we didn't want to trust the client with such important game mechanical decisions and just like that you have to consider every single mechanic you have whether it's looting a chest or firing a projectile or calculating damage you want to make sure that the server has authority that the server is the decision maker in your network otherwise the client is definitely exploit sensitive and that could mean that players can get themselves unfair strategical advantages that would break your game balance the third element that i want to talk to you about is lag compensation lag compensation is a technique or a method that well we haven't really been talking about it haven't thrown around the term yet i believe on this tutorial series but it could be very important to implement especially for those that are doing a fps like a multiplayer shooter or a battle royale or something like that imagine this situation you have somebody in your scope so you got a sniper rifle you got somebody you use code and you pull that trigger and that pulling the trigger of course then sends that signal to the server the signal is going to check but you hit something the thing is you are playing a game that is a hundred milliseconds in the past due to the interpolation offset so by the time that the server receives that attack considering also the interpolation offset combined with that latency means that that head of the enemy that wasn't your scope actually is not in scope for the server but that's of course a a situation that is undesirable we want the player if he has his scope on the correct location and he's got that enemy head right inside if he pulls that trigger and that's supposed to be a hit then we want it to be a hit so for this we got lag compensation it's a technique in which we store a number of world states junk states or snapshots on the server however you want to call that and when a attack signal is received based on the synchronized clock we rewind the situation the physics situations of the world at that particular moment and then we run the calculations if that bullet actually hits somebody now of course that means you have to retain a history you have to do quite a lot of math in in that regard that math might even go that far that you can completely erase the server maps on your server so then all the collisions will be done in code instead of in the dimensional space that we have now got through a server map so that could be a way of optimizing your code and in some cases especially that fps shooter situation is actually necessary to make sure that the game feels like you wanted to feel moving away from lag compensation and if you want to know more about that i suggest you google there's quite a lot of resources on it let's move into the network architecture stuff and here we got two topics we want to talk about one is the load balancing and two the server handoffs a server handoff to start with that one is the moment that you want a player or a group of players to move from one server to another server this could for example be the case in case of a matchmaking server or lobby sitting in front of a number of game servers the player arrives in the game and the lobby finds a team or finds an enemy or both and is then handed off by that matchmaking server to the game server you want to disconnect those players from the lobby or matchmaking server so the lobby or matchmaking server has more room left to accommodate more other players that way you can have one matchmaking server and many many many game servers that are all being serviced by that one matchmaking server so you want to make sure that you hand off those players correctly but also at the same time in a way that no exploits are possible so you want to make sure that they properly verified etc so this is called a server handoff it's not a term you can google on and look into for yourself i'll probably make a tutorial on this in the future at some point it's just not something that i want to get into right now that's also true for the next topic load balancing load balancing is basically the practice of balancing the load between various servers this is usually necessary when there's no matchmaking or lobby server that the player logs into first but the player is straight logging into an actual game server we have game servers that are responsible for the same world or the same region and we want to make sure that a newly connecting player is connecting to the server that has the most head room available to it has the most cpu left and the most memory left or maybe currently has the least amount of players logged in at that particular time that way we balance the load hence load balancer between our various servers to make sure that all of our players have the best possible experience this also means of course that we have to make sure that our authentication server is sending its verification tokens to the correct game service that the player can log into the right server so it's a couple of things that are related to that load balancing i'll probably make a tutorial on this in the future as well as i'm going to need to build one myself anyway for the game i developed myself so once i've got that for my game i'll probably turn it into a tutorial and extend this series a little bit further for now though low balancer is an industry standard term so it's definitely something you can google on and find something about yourself the third topic in terms of network architecture i know i cannot count it's very difficult for me but the third one is actually starting up new servers automatically this is usually necessary when you have a couple of servers on standby so let's take a situation to make this a little bit easier to imagine let's say you have a map and you have four regions and for each of these four regions you have by default two servers that are handling the load the population of those four different regions now it can very well be the case that you can run 10 servers software wise on one hardware server on one cpu if that's the case that means that on a cpu that can handle 10 servers you got well eight servers by default for these four regions and you got two servers that you basically have headroom for and you can put on standby and as soon as one region becomes particularly busy you spin up a third server temporarily for that particular reason reason region until that load comes down until the population comes down maybe a peak load of the game is over with everybody logging in or maybe you have a couple of parties roaming around on the map and you know they go from one region to the other region and as they move around you got to make sure you got some head room there so in that case you want your server based on the data of the load balancer to automatically start up new servers and be included in the pool of servers that the load balancer can choose to send players to now that's of course going to be even more interesting when that expands out to several hardware servers regionally in several different regions so it can get quite complex there but it's definitely something you want to look into once you get further into your development at this point you should pretty much be in stage before you really start to worry about that so it's not something you have to worry about when you're still designing your architecture making a game for the very first time but it's definitely something that you will have to start getting to look into at the end of this multiplayer journey that you're on the next topic that i want to talk about is code optimization of your server and we talked about this a little bit way back in september so let's recap and i want to make some additions to that so first of all what you can do to optimize your code is to migrate it to c plus plus a c plus plus executes way faster than gd script you're you're talking serious performance increases uh up to more than 40 percent in some particular situation so definitely worth considering for your most intense or most often called functions the synchronization loop for your players is for example a great first candidate for such a code migration now secondly in gold 4.0 we're going to get some considerable in performance improvements for a static typed gd script that might be a much easier conversion for you to do as converting doctype or dynamic typed gdscript to static type this is relatively easy and it won't require you to learn c plus in case you are not familiar with that language yet so uh gd script static typed in go.4 is going to get a performance increase from about 20 to 30 which is quite considerable uh considering that you'll probably be able to accommodate quite a lot more players through that method so instead of only considering c plus plus for your migration for performance optimization you may since go to four is going to come out and if you make use of gold.4 by then you may want to consider using a static type gd script instead if that fits your current skill set a little bit better and you don't want to invest time in c plus the last topic that i want to talk about is databases i know that a couple of you maybe more than a couple of you had hoped that i would do a database tutorial in this multiplayer series and you're actually right to say that i had actually planned it i think i mentioned it a couple of times even whether it was in the video or in the comments thing is there's quite a lot of different databases and over the last couple of months we've been having a lot of discussions in the discord channel like what's a good database what's a bad database what type of database sql nosql what kind of license would fit the goldup open source model which are not limiting us or which could be a threat for a future continuation of that database um how are they multifunctional in relation to various platforms is this a database that we can only use for a server or is that maybe the potential to also use it on a mobile device in the future there's tons of different databases like i was shocked when i saw the list for the first time and we've been going over that and we actually have a community member in a discord channel his name is secret he's a moderator and he's actually making modules for databases now and he's going to be making tutorials for them as well so i mean that's just super awesome there'll be written tutorials um so there won't be like in video format but i'm super excited for him to release that there will be a huge contribution to the community not just the game development center community but i hope just the entire golden community so do make sure you join the discord you know when when that stuff comes out when the modules are complete and the tutorials are done and uploaded there'll definitely be links everywhere on the discord so that you know everybody will be able to find the amazing stuff that he's working on um so that's a little bit like the update of databases you definitely want to get to a database at some point and i know if you if you watch this a couple of months down the road when this video has been uploaded then you know join a discord and probably you'll be able to find some links or ask around what the status is all right that was it for this video guys and with that for this multiplayer series i hope that all this terminology and jargon is helping you to you know do some google searching and and learn new things because that's definitely something that you have to do stay hungry for new knowledge keep on learning keep on developing stay motivated don't give up and if you ever need something uh like in terms of help or you just want to bounce some ideas of some other game developers do join that discord uh we can't help with every question but we can definitely all learn from any question that is asked by any individual so i wholeheartedly invite you to the discord server i hope to see you in the next tutorial series i'm working on the first episode should be out next week until then keep on gaming keep on coding see you later guys
Info
Channel: Game Development Center
Views: 2,724
Rating: undefined out of 5
Keywords: Godot Multiplayer, Godot Multiplayer Tips, Godot Multiplayer Hints, Godot Multiplayer Tutorial, Godot Network, Godot Networking, Godot Dedicated Server, Godot Multiplayer Server, How to make a multiplayer game, Godot MMO, Godot Beginner Tutorial, Godot 2d Tutorial, Godot Tutorial, Godot
Id: PLtqkIqbf34
Channel Id: undefined
Length: 13min 10sec (790 seconds)
Published: Sun Jan 31 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.