_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
31 | How to build a turn based multiplayer "real time" server I want to build a TCG for mobile devices that is multiplayer over the web (not local wifi or bluetooth). As a player plays cards I want the second player to see what is being played in "real time" (within a few seconds). Only one player can play at a time. Server requirements 1) Continuously listens for input from Player 1 2) As it receives input from Player 1, sends the message to Player 2 I know some PHP, but it seems like unless I had a loop that continued until I broke it (seems like a bad idea) the script would just receive one input and quit. On the mobile side I know I can open sockets using various frameworks, but what language allows a "stream like" behavior that continuously listens sends messages on the server? Or if I'm missing something, what would be the best practice here? EDIT I might have not made it clear before, but the mobile apps are native not web based. I guess I'm asking for specific suggestions on what some of the best tools or platforms for this scenario could be used i.e., PHP sockets, etc. |
31 | Lag Compensation in a Real Time Game I have been trying to implement some lag compensation techniques for a real time game, I've found some good resources online, but I don't think I fully understand the server side part of the problem. The game is a simple 2D game, where the player moves an entity around the map. There will be other entities with their own behavior that are controlled by the server, but I made it so that their movement can be easily interpolated. The player input is quite simple an analog stick and some commands (pick target, loot objective, etc.). The game runs at a fixed 10 TPS (it's on mobile and it's not that action packed, 10 TPS will suffice). The client will send the input state every tick (even if no input is present, like the analog stick is in the default position). It is worth mentioning that only one player is connected at the same time, so in a way this is not multiplayer, but I need to run this on the server as well to prevent cheating. I understand client side prediction and that's quite straightforward to implement. I am struggling with the server side part. As far as I can see I have 3 options The server waits for the input from the client then computes the new game state and sends it to the client. This is a viable option only because there is only one player. The server runs the game loop waiting up to 100ms (10 TPS 100ms tick) for an input. If it gets one, it will be taken into consideration when computing the next state, otherwise it will be discarded. If an input arrives after the tick was done, it will be discarded. If an input arrives during this timespan, but the tick numbers don't match (client send input for tick 5, but server is at tick 7) it will be also discarded. The server runs the game loop waiting up to 100ms (10 TPS 100ms tick) for an input. If it gets one, it will be taken into consideration when computing the next state, otherwise it will be discarded. In this case it will not care if the input is not for the current tick, it will apply it anyways. Option 1 is the easiest to implement and will be more consistent. The biggest issue with this is that I believe it's easy to cheat. Since the server is waiting for input, the player might be able to "pause" the game, analyze the situation then dispatch the action, basically allowing a cheating player to play in slow motion. The client side reconciliation in this case seems easy, when the player moves, it will move instantly on the screen and when it received the updated state from the server it will do it's reconciliation. Option 2 is a tad harder to implemented (not by much though), but it will be unplayable (literally, the player won't be able to move) if their ping is higher than 100ms. Option 3 has the same complexity as Option 2. It will work with pings higher than 100ms but it will most probably lead to some frustration on the player's side since their inputs will not arrive in time. Is there a better way to do this? What are your thoughts? |
31 | How does a wow server handle which player position to set to each nearest players? I already understood how game developers could create very large game levels, bypassing the floating point precision limit. This was my very first mind boggling question, and I understood it when I read how some programmer told the story of some dungeon PC game. My question is more related to game networking, more precisely wow. There are no interruptions in the game level (apparently I think). Since the viewing distance is much smaller than the world size, and since there are a lot of players, you can't send all players positions because it would require too much bandwidth so you have to only send the nearest players positions, among a pretty big list of connected players. Those servers are almost always online, with a large number of players (only doing quests or idling into cities, since I guess dungeons and raids must be hosted on dedicated servers), and they must find a solution to save as much bandwidth as possible. So at one point the server has to determinate which players positions it has to send to which players, and when it has to stop sending it. I was wondering about how the server does this, because to me it seems to have O(n 2) or even an O(2 n) complexity. How do they do it ? Do they fragment into virtual tiles so they only check players in the nearest tiles ? Do they calculate this not so often so that the server can handle it ? A continuous online persistent world is quite awesome, but technically I don't really know how they do it. |
31 | P2P synchronization can a player update fields of other players? I know that synchronization is a huge topic, so I have minimized the problem to this example case. Let's say, Alice and Bob are playing a P2P game, fighting against each other. If Alice hits Bob, how should I do the network component to make Bob's HP decrease? I can think of two approaches Alice perform a Bob.HP , then send Bob's reduced HP to Bob. Alice send a "I just hit Bob" signal to Bob. Bob checks it, and reduce its own HP, then send his new HP to everyone including Alice. I think the second approach is better because I don't think a player in a P2P game should be able to modify other players' private fields. Otherwise cheating would be too easy, right? My philosophy is that in a P2P game especially, a player's attributes and all attributes of its belonging objects should only be updated by the player himself. However, I can't prove that this is right. Could someone give me some evidence? Thanks ) |
31 | Client side Prediction and Reconciliation for movement I've explored the concept of client side prediction with reconciliation quite a bit and there's one thing that puzzles me a lot. From what I've seen in most guides, the flow looks a bit like this T0. Client sends MOVE command and immediately simulates a predicted result. T0. Server streams gamestate (server does not know about Client's MOVE command yet and thus the T0 gamestate does not contain results for it). T3. Client receives gamestate T0 from the server. T0 does not contain any movement and thus Client is forced to reconcile with the Server gamestate. This way, Client will have to reconcile with the Server every tick it receives because they will never agree. If Client would be delayed by RTT before predicting, Client and Server should agree most of the time, but that's an unwanted delay. If the Client submits a tickstamp with each command sent, the server can apply those commands pasttime. But this would mean that the client is authorative because it can make the server reconcile with its commands. There's also an issue here where players with a high latency will be changing a relatively distant past on the server, potentially undoing invalidating a lot of already streamed gamestates. I suppose the Client could simply pretend that T3 is T0 (sync to a different server tick depending on how high the latency to Server is) but I don't know the effect of that when interacting with other non predictable entities (such as other players). I guess the Client would take longer to reconcile with the correct Server gamestate because of the induced "tick latency". Is there something I'm missing here? Which is the best way forward for a twitch gameplay competitive game? I.e. Air Hockey or similar. |
31 | network programming simultaneous IO over sockets? In my curses based game, I decided to add multiplayer functionality over net, in addition to one keyboard mulitiplayer game. I use switch loop and in case it's 1st user's buttons, user 1 is acting appropriately and second otherwise, without blocking each other's movements i.e not waiting for opponents move. Now I read socket tutorials, and use server looking like this wait for 1st user to connect wait for 2nd user to connect loop read from 1st write to 2nd read from 2nd write to 1st Now problem is obvious, players would block each others movements, how this network multiplayer problems solved in games design? |
31 | How to reduce server traffic for 100 multiplayers game? I'm working on fast paced multiplayer game which has 100 players in single session. To sync entire game state to each player, server should send massive data if I did not any compression 24(transform per object) 100(total objects) 100(total players) 30(server update frequency) 7.2MB s ! This is completly unacceptable size. So I investigated someting technique for recuding packet size (like https gafferongames.com post introduction to networked physics ) Maybe I can reduce data size of (transform per object), by using quantization, Y axis only rotation and so on. Also, there is chance to reduce (total objects) for specific player (ex, send only near or visible object for that player). Reduced packet size example is (worst case) 16(transform per object) 30(visible objects per player) 100(total players) 30(server update frequency) 1.44 MB s ! I think this is still large for server! Is there any technique for more optimizing packet size? Another question, if I sending large block of state packet, should I split entire payload into small UDP packets for avoiding fragmentation? (application level packet fragmentation and assembling is efficient?) Thanks. |
31 | Acknowledgement reliability using UDP I have a question about UDP. For context, I'm working on a real time action game. I've read quite a bit about the differences between UDP and TCP and I feel I understand them quite well, but there's one piece that has never felt correct, and that's reliability, and specifically acknowledgements. I understand that UDP offers no reliability by default (i.e. packets can be dropped or arrive out of order). When some reliability is required, the solution I've seen (which makes sense conceptually) is to use acknowledgements (i.e. the server sends a packet to the client, and when the client receives that message, it sends back an acknowledgement to the server). What happens when the acknowledgement is dropped? In the example above (one server sending a packet to one client), the server handles potential packet loss by re sending packets every frame until acknowledgements are received for those packets. You could still run into issues of bandwidth or out of order messages, but purely from a packet loss perspective, the server is covered. However, if the client sends an acknowledgement that never arrives, the server would have no choice but to eventually stop sending that message, which could break the game if the information contained in that packet was required. You could take a similar approach to the server (i.e. keep sending acknowledgements until you receive an ack for the ack?), but that approach would have you looping back and forth forever (since you'd need an ack for the ack for the ack and so on). I feel my basic logic is correct here, which leaves me with two options. Send a single acknowledgment packet and hope for the best. Send a handful of acknowledgment packets (maybe 3 4) and hope for the best, assuming that not all of them will be dropped. Is there an answer to this problem? Am I fundamentally misunderstanding something? Is there some guarantee of using UDP I'm not aware of? I feel hesitant to move forward with too much networking code until I feel comfortable that my logic is sound. |
31 | Should I ping for a TCP based game? I have a head to head game where two players communicate through a server based on TCP. I am planning to implement a ping pong mechanism in order to detect network disconnection situations. For example, A pings B every 500ms. If A receives no response from B, A shall consider B is disconnected. If A receives no response from the server, A shall consider A is disconnected itself. Do you think this ping pong system is needed or other method is recommended? |
31 | Send regular keyboard samples OR keyboard state changes over network Building a multi player asteroids game where ships compete with each other. Using UDP. Wanted to minimize traffic sent to server. Which would you do Send periodic keyboard state samples every from client every to match server physics update rate e.g. 50 times per second. Highly resilient to packet loss and other reliabilty problems. Out of date packets disacarded by server. Generates a lot of unnuecessary traffic. Only send keyboard state when it changes (key up, key down). Radically less traffic sent from client to server. However, UDP can lose packets without you being informed. So the latter method could result in the vital packet never being resent unless I detect and resend this in a timely manner. |
31 | How to synchronize actions like jump in multiplayer? I am a newbie game developer and I have been researching about multiplayer games. I observed that there's always some latency, the players always get updates from past actions. But there are techniques like dead reckoning to handle the latency. I can predict the movement and make movements smooth. But how would I make actions synchronize like jumping, stopped walking, etc. Suppose, client A was moving, he was at 100m at 10.2 time with 100m sec velocity and sended this information. Client B would receive this information somewhat later, let it be 10.4. So at client B, I can use prediction and place client A at 120m. But what if, client made a jump at 110m at 10.3. I can't predict that and since I have been using prediction I can't show client A jump in past. I may deal with this problem by not sending jump action at all. But what if my game has some voids where players can fall and die. So, If I don't sync jump actions, other players will observe that one player was running then he falls in void and then again appear on the screen destroying the visual engagement. Jump is just an example, there might many scenarios where prediction can't work. So, How do deal with them. One such example can be Multiplayer Online battle arena games like Awesomenauts. |
31 | Why do multiplayer games chat services ever need to be able to open all NAT ports? I understand that games need to be able to open NAT ports in order to receive incoming connections. What I do not understand is why there is an issue between "limited" and "open" NAT. The only reason I can see that a game would ever need to have the flexibility to open any port is if it is intending to accept incoming connections on ports that aren't specified in advance as part of the protocol. (If there was a restricted set specified in advance, forwarding these and no others should satisfy all of the game's demands for NAT forwarding, meaning that "open" would not need to be a thing.) This seems to imply there's some port negotiation going on as part of the protocol (otherwise how does the connector know that this port, not specified in advance, is available?) but if a connection is already established to conduct the negotiation, why move to a different port? And even then, why can't negotiation be limited to a subrange of ports rather than the entire range? |
31 | How do I avoid users hacking my network games from the client side? I've decided to make an online game the server sends packets of information to the client application, which is going to simulate what it gets from the server. The client makes a part of the design of the game, and sends the new state back to the server for processing. The clients can send fake information to the server, and inform the server that I've done the task successfully, without trying. Assume a Counter Strike game the client may send a fake packet to the server and tell the server that I've defeated someone. How can I avoid this violation? |
31 | PlayFab Custom Server Integration I want to use PlayFab to host and manage my server instances but I'm unclear on how to implement the requirements they listed here. My server SDK is in .Net and I'm hoping I can fulfill all the requirements with plugins written in C . How can I and make parameters available in the command line input? Am I supposed to return information by printing on the console? |
31 | How to synchronize events to clients? I need to keep the client updated on data that's rarely changed (like health) or when an event occurs (like when a player is attacked and should have " 10 hp" above him). Those 2 specific part should be interdependent btw. I need a way to instantly send this data to clients (or just without big lag), without resending it too many times and I need to be sure the clients received it. I cannot just send a request to the client when something happens, because I'll just be sending a lot of tiny messages to a lot of clients and that's bad for performance. I was thinking of accumulating packets of data (per client) and sending them no more often than 5 times a second and then if the client doesn't say he got a package just resend it. This way if nothing happens there is no overhead and if a lot of events are going on I'm sending them in bigger packets. Is my solution good? Is there a better, more popular way of dealing with this? |
31 | How do I let game maker know that recieved json data is an array? In python I created an array called lobbyList "Awesome","Funny","Epic" I sent this array to Game maker studio 1.4 using JSON, I made a variable called RecievedData and made the following script var name argument0 var data argument1 RecievedData json decode(data) show message(RecievedData) Let's me know data has been recieved I can recieve data fine, but when I show message(RecievedData) it returns 4, when I do show message(data) it gives me a string of "Awesome","Funny","Epic" So how do I tell game maker that this is an array and not just a number or string? I want to draw this array coming from the server into a lobby list but for the life of me, I can't figure out how say this is an array. |
31 | Client send rate for network games As I understand for a client server model, it's common practise to send input to the server and then the server applies the input to update the state of the game. The server then sends updates to clients regularly. The client in the meantime does prediction, before it receives the "true" state. My question is how often to send input. Surely it should be sent every frame otherwise some input (during frames which are not sent) will not be processed by the server. Will this be too heavy for the network. What is common practise? |
31 | Should the server calculate the time of a player's input, or trust sent data? I am curious about the details of lag compensation in games. I have read a lot of articles about it, for example Source Engine Multiplayer Networking Fast Paced Multiplayer Gabriel Gambetta How do Multiplayer Game s sync their state? And I still have this question At the 1st link, the Valve developers give a formula to compute the time when the command should be executed Command Execution Time Current Server Time Packet Latency Client View Interpolation But on the 3rd site, the author says that the client sends the Command Execution Time and the server does not need to use that complicated formula to calculate something that the client can give the server for free. I mean, the player will always send the correct info about Command Execution Time, so the server can believe him. Which one is correct? Or are both suitable (for different situations)? |
31 | Multiplayer tile based movement synchronization I have to synchronize the movement of multiple players over the Internet, and I'm trying to figure out the safest way to do that. The game is tile based, you can only move in 4 directions, and every move moves the sprite 32px (over time of course). Now, if I would simply send this move action to the server, which would broadcast it to all players, while the walk key is kept being pressed down, to keep walking, I have to take this next command, send it to the server, and to all clients, in time, or the movement won't be smooth anymore. I saw this in other games, and it can get ugly pretty quick, even without lag. So I'm wondering if this is even a viable option. This seems like a very good method for single player though, since it's easy, straight forward (, just take the next movement action in time and add it to a list), and you can easily add mouse movement (clicking on some tile), to add a path to a queue, that's walked along. The other thing that came to my mind was sending the information that someone started moving in some direction, and again once he stopped or changed the direction, together with the position, so that the sprite will appear at the correct position, or rather so that the position can be fixed if it's wrong. This should (hopefully) only make problems if someone really is lagging, in which case it's to be expected. For this to work out I'd need some kind of queue though, where incoming direction changes and stuff are saved, so the sprite knows where to go, after the current movement to the next tile is finished. This could actually work, but kinda sounds overcomplicated. Although it might be the only way to do this, without risk of stuttering. If a stop or direction change is received on the client side it's saved in a queue and the char keeps moving to the specified coordinates, before stopping or changing direction. If the new command comes in too late there'll be stuttering as well of course... I'm having a hard time deciding for a method, and I couldn't really find any examples for this yet. My main problem is keeping the tile movement smooth, which is why other topics regarding synchronization of pixel based movement aren't helping too much. What is the "standard" way to do this? |
31 | Should I switch to UDP for a mobile p2p game when considering 3G network? I have been making a mobile game that is similar to "Street Fighter" where two players play with each other via Internet. The game sends out a small packet (controller status) to the other party every 30ms (a lot of packets going on). I am currently using a server to connect two players and all communications are via TCP through the server. The server load increases a lot even for just 30 concurrent players. I know it sounds not wise to let the communication go through the server, so I think the best design should let these two players to communicate directly via UDP after the server hooks them up. However, I have some questions when trying to move on to the new design Since it's a mobile game, players might be using 3G network a lot. Does UDP hole punching work well in 3G network? Does it matter when a player is actually moving physically (such as inside a car)? Do you think I should change the design or any recommendation of better design concepts? |
31 | How do we make online games deterministic? I am trying to understand how networking in games work as I am trying to make an online game myself. I can't grasp how it is possible to synchronize the players, in order to make the game deterministic. I found an article saying this in order to ensure that the game plays out identically on all machines it is necessary to wait until all player s commands for that turn are received before simulating that turn. This means that each player in the game has latency equal to the most lagged player. This makes sense and I also came to the same conclusion after hours of drawing graphs with various scenarios. However, there are some games where one player can have 500ms delay, and another player could have 40ms delay. In this case, how is the game deterministic ? Lets name players with 40ms, 500ms delay Player40, Player500 Lets say that Player40, shoots Player500 with an instant laser shot at T1 0ms. Exactly 40ms after the Player40 actually clicked with his mouse to shoot (so T2 40ms), The "laser shooting event" registered on the server and returned "ok, you can execute laser shoot" to Player40. So, the shot is being applied on Player40's machine and on his screen he sees that he killed Player500, and the corpse is lying on (x1,y1,z1). Meanwhile, what happened on Player500's machine, was that Player500 was running straight. A few moments later he sees a laser a few feet behind him, he dies even though the laser didn't hit him, and his corpse is lying on (x2,y2,z2). Since this scenario never happens in some games, does this mean that those games are deterministic ? How is something like this possible, without forcing all players to get a delay equal to the delay of the most lagging player ? |
31 | Using Unity's uNet to create a turn based RPG I've been checking some tutorials about uNet and it seems pretty powerful. The NetworkManager is a great tool when you want to make generic games, but what is troubling me about it is the need of spawning a "Player". I intend to create a turn based RPG, and for that, during the battle there's not a "physical player entity", there's two players which have a set of monsters and the players can select a monster to attack the opponents', but the player itself doesn't exist, in the end it sums up to a trade of commands between the clients. How can I achieve such an architecture with uNet? Should I discard the use of the default NetworkManager? Should I simply create a bodyless Player and go along with it? |
31 | Multiplayer netcode where all units, including server, are untrusted possible, feasible, etc.? Most professional video games use either a peer to peer architecture or a client server architecture. In the former, clients often trust each other, and instead employ anti cheat techniques to ensure that all clients are using the same version of the game. In a client server architecture, the company owned server manages the game, and each client only needs to trust the server without trusting any other client. My question is how might I write a game network architecture such that the server is not necessarily trusted either (e.g. it is another client, or is buggy, or has been compromised), and do so in a way that does not take too much processing power away from the game? I know that the blockchain algorithm (as infamously used by Bitcoin and other cryptocurrencies) does provide this as long as at least half of the computing power is owned by trusted machines. While this may work for long term actions (such as match verdicts), it doesn't work as well for the frame by frame actions of action games and can also be too slow for turn based games, to say nothing of the computing power it requires of the clients or of any dedicated servers. |
31 | Random Disconnects on UNET Using UNET, I can't host a game for more than a few minutes unless both server and client are on the same computer. It appears that I am not alone in this. Essentially, any latency problems or packet loss triggers an immediate disconnect. Rather than just getting lag, the client gets booted. Does anyone know how this could be dealt with? |
31 | How to perform game object smoothing in multiplayer games We're developing an infrastructure to support multiplayer games for our game engine. In simple terms, each client (player) engine sends some pieces of data regarding the relevant game objects at a given time interval. On the receiving end, we step the incoming data to current time (to compensate for latency), followed by a smoothing step (which is the subject of this question). I was wondering how smoothing should be performed ? Currently the algorithm is similar to this Receive incoming state for an object (position, velocity, acceleration, rotation, custom data like visual properties, etc). Calculate a diff between local object position and the position we have after previous prediction steps. If diff doesn't exceed some threshold value, start a smoothing step Mark the object's CURRENT POSITION and the TARGET POSITION. Linear interpolate between these values for 0.3 seconds. I wonder if this scheme is any good, or if there is any other common implementation or algorithm that should be used? (For example should i only smooth out the position? or other values, such as speed, etc) any help will be appreciated. |
31 | How can I implement a game locator or proxy server? I have a turn based strategy game which already has a multiplayer server client layer that works fine on local network (where one server is set up and players connect to it). I would like to extend this architecture to allow players to play via Internet, but I don't want to have a dedicated game server for that, especially due to performance issues. The game's AI is runs on the game server of course, and multiple games with computer players would "kill" the machine. I would like to have some kind of "central connection point" server that does not run the game logic, state or AI but can be used by players to find servers hosted by other players. How can I implement this? |
31 | Interpolation Jitter I am trying to interpolate players in a multiplayer game like so var lastTime now (1000 config.serverUpdateRate) for (var i 0 i lt players.length i) tmpObj players i var total tmpObj.t2 tmpObj.t1 var fraction lastTime tmpObj.t1 var ratio fraction total tmpObj.x UTILS.lerp(tmpObj.x1, tmpObj.x2, ratio) tmpObj.y UTILS.lerp(tmpObj.y1, tmpObj.y2, ratio) The server update rate is the frequency with which the server send the player positions. The x2 is the newest position and x1 is the position from the previous update. Now this works fine on my localhost and on an empty server. But as soon as the game server has around 60 people on it, it begins to stutter. I am assuming that this is because the positions are coming in at an inconsistent rate. How can I adjust for that in my interpolation? You can see the issue in action here http moomoo.io I have tried to simply interpolate without lerping, but the movement felt too floaty. Also client prediction is not an option in this case |
31 | Game networking , server send rate I've been writing some server code recently and I ran into a bottleneck. If a server is capable of sending data at 60hz, with 1 client it would send data to that client at 60z, with 2 clients this would drop to 30z, then with 3 clients to 20hz,etc... This is because the server can only send data to one client at a time, Is my logic correct here? For example, if I had 50 clients and I wanted each client to receive 60 updates per second the server would have to tick at (60hz x 50 clients) 3000hz!? Is there a more efficient way this is done? |
31 | Design Architecture of a game waiting room I have some experience in creating singleplayer games, but for a new project I want to implement also a multiplayer. I can imagine what kind of information (position, textureId, ...) i have to send over the network. But hey, I can't figure out how I "could" represent a game waiting room. Which means One player creates a new game (What happens here?Does the server code calls a new instance of the game, but does not start the game yet???) The player, who created the game then either waits for additional players(in maximum 4) or he starts a solo game (Should my game has something like a value for currentPlayers ? Or is this managed by server code?) Also can you explain what exactly server code means? Which common functions should it handle (in context of creating a game room)? How can I make sure, that other players can also start new games As you can see I am a complete beginner to networking, but i do know about TCP and UDP, but the only thing i have done with it was a simple echo server... What am i looking for are simple pseudocodes oder examples, but please explain briefly. |
31 | Fixed timestep, how to determine how far back other clients are simulated I'm working on networking code for a social MMO (very low intensity compared to an FPS) and have a question about fixed timestep. This answer does a good job of explaining the forward dating part of utilizing a fixed timestep, but doesn't seem to have the whole picture. If the forward dating was meant to account for the packet getting all the way through the server to the other clients, wouldn't it have to either take into account the latency of the most latent client in order to arrive in time, or deal with it being late? I assume this is where the "simulate other clients as being a few ticks behind" concept comes in. My question is how is this back dating offset calculated? Is it a single number for all other clients, or should it be variable through the server sending each client's latency? What goes into the calculation? I would assume that the starting point is any delay caused by differences in tick rate between the game tick and networking tick (e.g. game is 60 ticks s, network is 20 and both are in phase, you need to push clients back at least 2 ticks to let the server's network re tick.) Is this understanding accurate? |
31 | How to organize messages queue in a fast paced multiplayer game I'm trying to develop a fast paced multiplayer game. I decided to build my own protocol over UDP and now I'm stuck with the following question. The idea of the protocol is very basic and it's similar to many others Client does NOT do any game logic except of some predictions (like smooth walking). It just sends 'ping', 'connect', 'disconnect' and 'keypressed' 'keyreleased' actions to the server. On contrary, the server does game logic based on the users inputs and sends diffs to each client every 30 ms As I already mentioned, the client sends 'ping' messages (to notify server that we're still alive when there's no other messages in some period of time) as well as 'keypressed' 'keyreleased' stuff. I thought that the 'ping' messages can be unrelirable the client sends them at steady intervals anyway, so if one was lost, nothing bad will happen. However, such messages like 'keypressed' and 'keyreleased' should be reliable. By this I mean that the client should resend them in case of any failure and they should appear on the server in the same order they were sent (otherwise 'keyreleased' message could arrive before 'keypressed' resulting in the incorrect game behavior). So, the questions is how is it usually handled? I mean, what is the right way to implement such logic on the server? Should I queue all incoming reliable messages in some container and wait until messages with smaller sequence IDs also arrive? If so, what should I do with unrelirable messages then? Because I definitely shouldn't wait before 'ping' message arrived (and there's a chance that it won't arrive at all). Should I use a distinct sequence numbers for unrelirable messages or should I make 'ping' messages reliable as well? |
31 | How do you build a matchmaking service for an iOS turn based board game? I want to build a board game that matches players with similar skill levels against each other. Take for example a chess iOS app. Log in, and the game pairs you up against someone with a similar elo rating. But there's a network infrastructure they're using. I haven't been able to find a suggestion for what kind of network architecture I should use. I've tried Google and searching on YouTube for how to build a multiplayer solution, and I haven't been able to find anything specific. The closest thing I have is to just use the built in GameKit features Apple offers. Otherwise I have to use some things called REST, SOAP, Amazon AWS, or Unity's UNET multiplayer matchmaking service. And that's all fine, but I haven't been able to find any specific directions on how to use those services. What I'm trying to say There doesn't seem to be a stock, default solution for multiplayer matchmaking in 2018. What should I use? What can I use? Should I just stick to the basic Game Center functionality? Should I explore other services or take a few months to build a custom solution? What's the most efficient route towards building a multiplayer server for a simple board game between two players? |
31 | How do I prevent identity spoofing in a multiplayer game? I'm thinking about clients spoofing IP addresses, tricking other clients that they are the server that sort of stuff. (I don't know much about this, so if this is completely wrong, please correct me.) What should I do to prevent this? Because it is a real time game, if I were to use encryption, I would use something fast and secure like RC4. Should I encrypt packet data with a key, that the server gives to the client? If it makes any difference, I'm using UDP. |
31 | Is there a library or a framework that handles networking in an RTS? I'm aiming for making a(n) RTS game with networking so instead of doing tedious stuff like networking I wonder if there is a library framework that will save me the effort. I intend to make that game in Unity if it is of any interest. |
31 | How to open auto detect LAN connections? After sucessfully creating my first online multiplayer with servers and clients in UDP, I am wondering how LAN connections works. As it is right now, I need to open a server and forward the ports for the server if public. In LAN, they connection is possible but requires the local IP address. However, if we take Minecraft or Starcraft, the game is able to auto detects servers on your local network. How are they achieving this ? |
31 | Implementing network smoothing We are making a multipler first person shooter. The client sends it's position to the server at a fixed rate (currently at 10Hz). The server sends a single message contatining all player's positions to all players at the same rate (10Hz). As expected, the movement is pretty choppy since the 60fps game is only recieving updates 10 times a second. What is the best way to smooth this movement? The most obvious way would be to interpolate between the last two packets, so that the interpolation finishes as we recieve a new packet. But this adds an instant 100ms delay for all players. The other way would be to use the velocity and acceleration inferred from the last few packets to predict where the player is before the next packet arrives, however if the prediction is wrong, the player would tend to jump as soon as a new packet is recieved. Does anyone know how AAA titles solve this problem? |
31 | Would adding delay to inbound traffic give you an advantage in online games? Wouldn't adding a latency delay to inbound traffic and limiting your download speeds to a low but playable standard give you an advantage in online games, especially shooters? Because wouldn't your shots be registering as normal (using upload outbound) while anything that attempts to hit you (download inbound) would be delayed and or slow? |
31 | How can I implement a game locator or proxy server? I have a turn based strategy game which already has a multiplayer server client layer that works fine on local network (where one server is set up and players connect to it). I would like to extend this architecture to allow players to play via Internet, but I don't want to have a dedicated game server for that, especially due to performance issues. The game's AI is runs on the game server of course, and multiple games with computer players would "kill" the machine. I would like to have some kind of "central connection point" server that does not run the game logic, state or AI but can be used by players to find servers hosted by other players. How can I implement this? |
31 | Networking with UDP, should I keep sockets open on the server I am working on making a 2D platforming game that will have multiplayer functionality. Over the last few days, I have done a lot of reading regarding how to deal with the networking, and believe that I am on the way to implementing some of the concepts I have read about. I have decided to go with an Authoritative server client model, where multiple clients will send actions made by the user to the server, client will predict the players next steps before comparing against the Authoritative reply from the server, etc. This seems to have been suggested in numerous corners of the web regarding games networking, and seems reasonable. Before jumping straight into trying to get snapshots sent from the server, I wanted to make sure that I had an idea of some of the technical nuances of a language, as conceptual knowledge can only get me so far. I have set up a simple Echo Server that has worked rather well for a single client, but now my next step is to have multiple clients connected to the server at a single moment, and have each message that is sent from a client echoed to all clients connected to the server. I feel that the answer might be language dependent, so I will mention now that currently I am using Java for the networking (a little bit of preliminary testing may suggest that Java has significant overhead in its network implementation, so I am open to change upon suggestion). I am using UDP for speed sake (and this seems to be what is predominantly suggested). My question is with the server, should I be keeping each DatagramSocket that represents a connected client open and send DatagramPackets directly out without ever closing them (until the program terminates, client disconnects, etc.), and have them stored in some form of Collection, or should I close them after each message is sent and create a new outgoing socket whenever I need to send a packet? There are obvious performance disadvantages of creating a socket whenever I need to send a message, but is there some fundamental reason that I have not come across that suggests leaving sockets open is not a good idea? |
31 | networking how to deal with serverside packet arrival delay? Let's assume each client sends a packet every 0.05 seconds. (rate 20) Server update tickrate is 60 and it sends data back to client every 1 30 seconds. Now client A has 50ms ping time and it sent each data at A 5, B 5.05, C 5.10 second. But due to some networking issue, server received each data at A 5.05(good), B 5.10(good), C 5.18(bad! it delayed 0.03 seconds.) When server get the packet A at 5.05 seconds, since each packet contains client data(like commands) for 0.05 seconds, it updates the entity based on this A packet for 0.05 seconds. after that, server time is now 5.10. and the next packet, B is already arrived so server just can keep updating. At 5.15, now server has to update the entity with next packet, which is C, but there's no packet! Server has to wait for 0.03 seconds till next packet will be arrived. now, server is behind 0.03 seconds from client. sync failed. I have two idea for solving this problem. Server maintains its own client's time and sends back to client. For client side, when there is heavy desync between client and server, the client syncs to the server time. Solution 1 is still applied. but there is one more. like entity interpolation, there is packet interpolation. Client sends each packets every t seconds which is (t SEND TICKRATE CLIENT LAG ) . It means server gets next packet after t LATENCY seconds which is always larger than SEND TICKRATE, 0.05 in this assumption. So when server gets packet, it doesn't update it immediately but waits for some time (like 0.03 0.05 seconds). Now server has next packet with a high probability. I think Solution 2 is good. But the drawback is, client renders other player's data behind RTT Entity Interpolation time Server packet Interpolation time , so for a fast paced game, Shot behind the wall will more happen. What technique is used in other fast pace game like league of legends or overwatch? |
31 | How to synchronize the ball in a network pong game? I m developing a multiplayer network pong game, my first game ever. The current state is, I ve running the physic engine with the same configurations on the server and the clients. The own paddle movement is predicted and get just confirmed by the authoritative server. Is a difference detected between them, I correct the position at the client by interpolation. The opponent paddle is also interpolated 200ms to 100ms in the past, because the server is broadcasting snapshots every 100ms to each client. So far it works very well, but now I have to simulate the ball and have a problem to understanding the procedure. I ve read Valve s (and many other) articles about fast paced multiplayer several times and understood their approach. Maybe I can compare my ball with their bullets, but their advantage is, the bullets are not visible. When I have to display the ball, and see my paddle in the present, the opponent in the past and the server is somewhere between it, how can I synchronize the ball over all instances and ensure, that it got ever hit by the paddle even if the paddle is fast moving? Currently my ball s position is simply set by a server update, so it can happen, that the ball bounces back, even if the paddle is some pixel away (because of a delayed server position). Until now I ve got no synced clock over all instances. I m sending a client step index with each update to the server. If the server did his job, he sends the snapshot with the last step index of each client back to the clients. Now I m looking for the stored position at the returned step index and compare them. Do I need a common clock to sync the ball? EDIT I've tried to sync a common clock for the server and all clients with a timestamp. But I think it's better to use an own stepping instead of a timestamp (so I don't need to calculate with the ping and so on and the timestamp will never be exact). The physics are running 60 times per second and now I use this for keeping them synchronized. Is that a good way? When the ball gets calculated by each client, the angle after bouncing can differ because of the different position of the paddles (the opponent is 200ms in the past). When the server is sending his ball position, velocity and angle (because he knows the position of each paddle and is authoritative), the ball could be in a very different position because of the different angles after bouncing (because the clients receive the server data after 100ms). How is it possible to interpolate such a huge difference? I posted this question some days ago at stackoverflow, but got no answer yet. Maybe this is the better place for this question. |
31 | Multiplayer tile based movement synchronization I have to synchronize the movement of multiple players over the Internet, and I'm trying to figure out the safest way to do that. The game is tile based, you can only move in 4 directions, and every move moves the sprite 32px (over time of course). Now, if I would simply send this move action to the server, which would broadcast it to all players, while the walk key is kept being pressed down, to keep walking, I have to take this next command, send it to the server, and to all clients, in time, or the movement won't be smooth anymore. I saw this in other games, and it can get ugly pretty quick, even without lag. So I'm wondering if this is even a viable option. This seems like a very good method for single player though, since it's easy, straight forward (, just take the next movement action in time and add it to a list), and you can easily add mouse movement (clicking on some tile), to add a path to a queue, that's walked along. The other thing that came to my mind was sending the information that someone started moving in some direction, and again once he stopped or changed the direction, together with the position, so that the sprite will appear at the correct position, or rather so that the position can be fixed if it's wrong. This should (hopefully) only make problems if someone really is lagging, in which case it's to be expected. For this to work out I'd need some kind of queue though, where incoming direction changes and stuff are saved, so the sprite knows where to go, after the current movement to the next tile is finished. This could actually work, but kinda sounds overcomplicated. Although it might be the only way to do this, without risk of stuttering. If a stop or direction change is received on the client side it's saved in a queue and the char keeps moving to the specified coordinates, before stopping or changing direction. If the new command comes in too late there'll be stuttering as well of course... I'm having a hard time deciding for a method, and I couldn't really find any examples for this yet. My main problem is keeping the tile movement smooth, which is why other topics regarding synchronization of pixel based movement aren't helping too much. What is the "standard" way to do this? |
31 | How does the 3G network assign IP to smartphones? I am playing a game on the 3G network using Android or Iphone. Suppose I am moving from one cell to another Will the IP Address change? If yes, then how can I continue the same game while changing the base station, as my IP address is already registered in The game server? Is there something DHCP? |
31 | NavMesh LoS and "Containing" For a gameserver backend, I have a navmesh for "walkable" areas in form of points triangles. Now I want to check every gametick if the client is still in a legit place and if he shots casts a spell, if his target is in line of sight. I found several possibilities, but I am not sure what is performance wise ideal. To check if the player is still in the allowed area (and not wallhacking) I would check if his position is in one of the triangles with a algorithm using barycentric coordinates like this https github.com SebLague Gamedev Maths blob master PointInTriangle.cs But this would mean that every gametick I have to check soooo much triangles. To check if its LoS I could either check if the line from the player to its target crosses one of the "border" lines of the mesh (which have no other triangle next to it). Those border lines could be computed at bake time and are just a static list for each level. But still it would be a lot lines per check. Second option I found would be to start a Simple Stupid Funnel Algorithm (http digestingduck.blogspot.com 2010 03 simple stupid funnel algorithm.html) until LoS is broken. The questions now are How does a good gameserver handle this can it be optimised? What way to check is the best fastest? Is it common to only check if the position is legit every now and then or every gametick? The Levels are fairly simple ( 300 mesh triangles, 200 border lines, 10 players, 10 npcs maybe) |
31 | Should I use threads to check sockets for multiplayer game? In a multiplayer game does the code to get send info from to sockets reside in the game loop or does it belong in its own thread? |
31 | NodeJS client gameloop running slightly faster than server gameloop So I'm working on a real time multiplayer game in NodeJs (Client and Server). Both loops handle the same "physics" (movement at a constant rate) and both are running at 40hz or 40 times per second. I am using setInterval on both client and server with a delay of 40ms. The issue is that my server average delta between each tick is 41 and my client average delta between each tick is 40. This leads to results like this See in the last result, there is a difference of 46 ticks meaning the client is rendering about 1.8 seconds ahead of server time. My first guess on solving this is to sync the client every so often but that would lead to it "teleporting" backwards quite often due to how much it is desyncing. |
31 | Securing a TCP connection on iOS for an MMO I am currently building an iOS MMO and I'm leaning towards using TCP as my networking protocol over the higher level HTTP (for the speed difference and the fact that it does not require the client to poll constantly for updates.) Now, through my research I know that with MMO and any client server multiplayer games, you should never trust what the client sends to the server. As an extension of that, you wouldn't want anybody to read your packets to see the contents so it's harder for them to send correctly formatted data to the server. (Maybe I'm paranoid.) The only problem is, where in HTTP there is great support for a secure channel in HTTPS through SSL where the setup occurs mainly server side, I am not aware of a way to achieve the same thing on TCP. Is there any resource I could be referred that could help me achieving similar security, or at least good enough, on both the iOS side and server side? On a side note, if the answer involves doing the encryption and decryption on the client side, would that severely impact the performance of my application? Thanks! |
31 | Using peer to peer for prediction in a client server network model By implementing peer to peer connections between clients in a client server network model I should be able to increase the prediction fidelity as this theoretically would provide the client with other clients commands for a given tick earlier than it would receive the servers game states for the same tick. One problem I can think of is that clients would have to be able to interpret other clients commands (usually they just have to listen for game states, not commands). This would be a little bit like an RTS model I guess. This should be solvable without any negative effects on gameplay. Another problem is that clients could cheat by sending fake data to their peers when it is beneficial to them. This can be mitigated by having the client aware of the real commands through the server and have them immediately stop listening to any clients that fed it false data. This should therefore be solvable with different degrees of negative effect on gameplay depending on the design of the game and how impactful a few ticks of wrong command info is at the worst possible moment. (Unfortunately, you can't have the server punish any client because it has no idea who's lying, it can only help clients themselves understand if they are being lied to by providing them with correct data). Am I correct in assuming that this would increase prediction fidelity or is there something I'm not accounting for? The idea is that this allows the client access to some information about the other clients faster than in a traditional non peer to peer model where it would base predictions solely on its own commands. |
31 | What is the impact of many AI enemies on state replication networking? Imagine an online coop style FPS or TDS game where say 2 6 real players fought large amounts (20 60 concurrent) of AI enemies. Could this style of game be reasonably networked over the internet using a Quake or Tribes style partial state replication model? Almost every coop game I know of uses a lockstep style networking in these cases (even games like Halo which use state replication for normal multiplayer, but lockstep for coop firefight). My concern is that the network download (for clients) and upload (for server) overhead of each AI would end up being about the same as if a real player was in the game. Is this a real concern? Or is the limiting factor on the number of players more about how much data the players upload? TLDR Can large numbers of AIs be reasonably networked to a few players with a partial state replication model or is lockstep the only real solution. Any help here would be great! |
31 | What is better? Lots of small TCP packets, or one long one? I am sending quite a bit of data to and from a server, for a game I'm making. I currently send location data like this sendToClient((("UID " cl.uid " x " cl.x))) sendToClient((("UID " cl.uid " y " cl.y))) sendToClient((("UID " cl.uid " z " cl.z))) Obviously it is sending the respective X, Y, and Z values. Would it be more efficient to send data like this? sendToClient((("UID " cl.uid " " cl.x " " cl.y " " cl.z))) |
31 | How to design a server for a multiplayer game? I'm trying to write a multiplayer game where players join small matches with other players. What I also want is a way for players to login and go online. How would I design the a server that could handle logging in, matchmaking and the actual running of the match? I'd like to have multiple threads on the server to handle input from all the players, but I'm not exactly sure what I want to put in a single process and what I want to split apart. How would I set up the sockets for something like this? I'd probably end up having this run on Amazon EC2 or something similar if that makes a difference. I was planning on making the game a MOBA where there would be a small number of players (6 10) and latency would be relevant. |
31 | Do I need TCP socket? My game uses UDP sockets to stream updates between server and client and I've also made a reliable channel that resends messages if there's no response and makes sure same message isn't processed multiple times. But TCP is specifically designed to be reliable and the people who made it probably have more experience than me. So would it be good to use TCP to send commands such as "attack", "play animation", etc. instead of my UDP implementation? (Of course I mean TCP sockets that don't delay sending the data (Nagle algorithm)) |
31 | Some practical issues with component based game object systems I am creating my own game engine just for fun and brain development. I have chosen various free and open source libraries to integrate and now I have come to the engine architecture. I intend to use server client architecture and I prefer to be more "data driven" so I can organize my game state in MySQL database. I recently read about a component based design which plays nicely with data driven systems. The idea is that game object components are bare properties and the behavior is implemented in so called subsystems. Each subsystem (like Physics, Render, Animation, Sound) "knows" only about related components and also is able to tie itself to other systems if needed. Those subsystems are singletons (single instances). I can use the observer pattern so each subsystem can subscribe to property changes which are important for the particular subsystem. The subsystems subscribe to prop change events in some particular order thus creating subscription chains. But this can create one problem SystemA detected change in propA and needed to change some propB, but SystemX is listening to propB changes and affects propA .. and we have an infinite loop. Is this a common weakness of such systems or I have wrong implementation ideas? The last system in the subscription chain could be the NetworkSystem, which sends out a small package on every subscribed property change ... or it is a bad idea and I should pack more changes together?. I guess, rendering and physics will be separate threads where RenderSystem (client side only) is polling the entities for their properties which have changed since last frame and PhysicsSystem is modyfing properties on each iteration InputSystem (client side only) and NetworkSystem also are modifying properties and WorldClockSystem could modify some properties on timer events. But the major problem is when I think how to implement custom scripting in such systems. Let's say, users are allowed to upload their custom logic and animation script called Respect which has one property called goodDeeds with a rule "if a person with goodDeeds 100 passes by, I run some RespectAnimation". So I would install a global RespectSystem which subscribes to position changes of every character and checks for the Respect component and goodDeeds property and then somehow tells to Animation system to run Respect animation on this object. Is this the way it is supposed to work, isn't it dangerous that the behavior now is a global object and not a property of the entity which uses it? If I think again about the problem of neverending loops of observed modified properties, it means that one wrong xxxSystem script could stall the entire server (but from the other hand, the admin of the server should have enough sanity to see such problems before allowing the user to upload that script). Anyway, it would be great to find some book or article which better describes how to use component based systems where components are properties and behavior are singletons, but somehow all articles I have read, explain only the idea itself but not how to attach it to a real game engine with scripting and networking. |
31 | Connecting clients with UDP and WebSocket connections I'm in the process of making a physics intensive multiplayer game. Naturally I use a UDP to transfer packets regarding rigidbodies between client and an authoritative server. However non essential packets I'd prefer to use a more reliable connection like WebSockets. This would be for things like voice chat, text chat, scoreboard, etc. It also seems the be a nice approach to checking if the client is still connected and if not, stop sending it UDP packets. I'm actually unable to find use cases of this dual connection approach online and I was wondering how this is typically handled in similar games. Is it very far fetched or unconventional? Another question would be how far do I take relying on the WebSocket connection? Lets say for managing remaining bullets in a guns magazine, would it be better over UDP or WebSocket? I feel like WebSockets would be best in this case because if the bullet was successfully spawned and the server needs to remove a bullet from the client's gun's magazine, if that packet doesn't arrive at the client, then they shot a free bullet... The UDP equivalent for this scenario would be to always send the client's magazine state as packets and the client just updates it's magazine whenever the packets get to them. My concern here is overloading the network traffic data that might not have even changed... |
31 | Applying the input for the always moving player in the multiplayer game I've read several articles published on gambrielgambetta.com, gafferongames.com plus some pages about how Valve handles multiplayer networking in its games but I still can't get it how to implement the client side prediction for my game where the player's always moving and he controls the speed by pressing the spacebar. When the client input has arrived the server already had simulated the world using the old velocity values. So we get a stretch in time. Let's imagine that the player is moving between the 0.0 and 1.0 values. The current position is 0.2. The normal speed is 0.1. The "crawling" speed is 0.05. Let's assume the server and the client have framerates both fixed and the latency is two steps high. STEP 0 server 0.2 client 0.2 STEP 1 server 0.3 ( 0.1) client 0.3 ( 0.1) STEP 2 server 0.4 ( 0.1) client 0.4 ( 0.1) STEP 3 (Spacebar's pressed) server 0.5 ( 0.1) client 0.45 ( 0.05) STEP 4 (Spacebar's still pressed) server 0.6 ( 0.1) client 0.5 ( 0.05) STEP 5 (Spacebar's still pressed. Finally, the input has arrived) server 0.65 ( 0.05) client 0.55 ( 0.05) STEP 6 (Spacebar's still pressed) server 0.7 ( 0.05) client 0.6 ( 0.05) STEP 7 (Spacebar's released. Input was sent) server 0.7 ( 0.05) client 0.7 ( 0.1) STEP 8 server 0.75 ( 0.05) client 0.8 ( 0.1) STEP 9 (Input has arrived) server 0.85 ( 0.1) client 0.9 ( 0.1) It looks like nothing's wrong with this data while every multiplayer game's trying to hide the latency. But what if the periods of pressing the spacebar are different and the latency is different and the server and client have different framerates. I can't use the input duration when updating the player position because it allows the player to cheat (just lower the duration and you will start moving slower). And the server reconciliation works not very good since I'm getting the effects derived in the statistics above. When pressing the spacebar the player just jumps back and starts moving slower. So I need to compensate that somehow. The core of the problem is how to handle the player input when the user can only decrease the speed of the character while the character's moving with the predefined speed. |
31 | Using Unity's uNet to create a turn based RPG I've been checking some tutorials about uNet and it seems pretty powerful. The NetworkManager is a great tool when you want to make generic games, but what is troubling me about it is the need of spawning a "Player". I intend to create a turn based RPG, and for that, during the battle there's not a "physical player entity", there's two players which have a set of monsters and the players can select a monster to attack the opponents', but the player itself doesn't exist, in the end it sums up to a trade of commands between the clients. How can I achieve such an architecture with uNet? Should I discard the use of the default NetworkManager? Should I simply create a bodyless Player and go along with it? |
31 | Implementing Multiplayer entire world ticks or just changes? i'm working an a very simple multiplayer experience (for now node.js, later will probably remake all in c , but my question is more about theory). All guides and tutorial i saw about making something multiplayer Always speak about sending all the "world" information, once per tick, deciding optimal tickrate, making smooth movements on client side with interpolation or stuff like that. Honestly i thought of another way, and i really cant see why its never mentioned. My idea would be the following Client sends to server when input happens eg if you move with arrows, you send to the server a message only when your moving status changed. If you was moving right and then start moving upright, then you send a message about you changing your movement. Server recives the messages, sets variable on player object for its movement, and sends to all other clients information about the change. Also sends current time and current position in the server at the moment of movement change. Clients recive a movement status update, place the player object in recived coordinates moved by the new movement ping delay. That way position in all clients should Always be up to date with the server. Why should i send hundreds of positions to each client per each player every x milliseconds when i can just send the changes? I feel like its about polling vs interrupt... (yeah i know its not polling anyway, but the concept is sending the change vs keep sending everything) |
31 | When doing network programming, is it always a good idea to optimize packet size as much as possible? My question is relatively straightforward, but I haven't been able to find a concrete answer yet. I'm programming a real time networked multiplayer game, and I'm finding many examples of places where I could optimize packet size (i.e. minimize packet size) in small ways. As an example, one packet type stores player input (running, jumping, firing a weapon, etc.) along with an integer ID for that player. In practice, there will never be more than four players in a single game, meaning that ID could be represented with only two bits (four possible values) rather than the full 4 byte integer. My question is, should I send only those two bits across in a network message or just send the full integer? To clarify, I'm not referring to storing the ID in the main code itself. For that, I'm just using an int. I'm only curious about what I should be sending in a network packet. That's also just one example of a few I've run into. The reason I ask is that this feels like a "don't prematurely optimize" scenario. Ordinarily, I know to not worry about optimization (within reason) until I've run profilers, but I'm less familiar with networking than "normal" programming. Is it better to optimize packet size as much as possible, or would that be overkill? Thank you. |
31 | Can networking be platform independent in a libgdx game? LibGDX supports Desktop (Windows, Linux and Mac), Android and web applications. Can i code the network part of an online game without taking care of what kind a of application i'm running? i.e coding the network engine interdependently of the application type. |
31 | Optimal data size for a 3G client server game? I'm currently working on an iOS turn based client server game and I am concerned over later performance issues. How much data per message is too big? I am planning to use JSON to transfer data (and, if possible, gzip it for more compression) and try to send as little as possible to make it work, but is there a figure I should keep in mind so that I do not exceed and is there a best practice way of compressing this data? On a side note, will this prevent me or affect whether I will use secure connections like SSL? |
31 | Where should multiplayer games start? Client or server? I'm starting to make a small multiplayer game, and even though I have experience with games and networking, there's just one thing that keep me from making this. The question is When starting a multiplayer game, should one start making the server first, or the client first? This looks like a dead lock for me, because while starting on the client, seems to be the a good option (you'll make a game, which you are already very good at doing probably, and you'll have something to look for progress), you will fall on the trap that probably most of the code effort you put into making that game will have to be thrown away and remade on the server side. And starting on the server side is just the opposite You'll have nothing to look upon, so you can't know if you're making progress. And if that wasn't bad enough, you'll also have to throw lots of stuff away, since you have no game to check if that will have to indeed work like that. Is there a correct answer for this? |
31 | Which server platform to choose I'm going to write a server for an online multiplayer with these requirements Pretty simple turn based game (think a card game) that is played entirely on the server (security reasons) Must be able to run multiple games (tables) with 4 players per table, but no lobby system required (another server takes care of that) Can support as many players at once as possible Might need multiple servers Chat between players Socket connection to a Flash AIR client Must be able to communicate with other servers (for player accounts and such) Now, I'm considering two options Smartfox (or equivalent) A custom Java solution in something like Tomcat Why Smartfox? It handles multiple rooms and chat natively It presumably has solutions for well known multiplayer gaming issues Why custom? Smartfox has many unneeded functions, bad for performance Smartfox communicates with an XML based format, I could use a more efficient binary one. Don't know if running the entire game model on the server is convenient with Smartfox' extension mechanism Multiple rooms and chat are easy to reimplement Tomcat or a lightweight container is easier to deploy than Smartfox Better IDE support for developing on Tomcat (automatic deploy, etc) What do you think? Are my assumptions correct? Do you have anything to add? What option should I choose (or maybe a different one entirely)? |
31 | Game synchronisation in peer to peer online multiplayer game I am developing an online real time multiplayer game using Google Play Game Service and Cocos2D X. The game has two players where each player control their own ball. The each player sends their own ball s velocity and position to the other connected device. In my game, all the physics calculations are done locally on each devices i.e. ball velocities after physical calculations are calculated locally on each devices. Issue When fast moving ball collides wth the opponent s ball, there is no change in the movement velocity of the opponent s ball. (According to real world physics, the fast moving ball should be able to push the opponent s slowly moving ball.) Reason During my code analysis, I understood that the velocity calculated by the local physics engine are overwritten by the data received from the opponent s device. For e.g. Solution I tried To fix the problem, whenever the collision between balls occurs I am creating one of the device as server and other device as client. All the physics calculations occurs on the server device and data is send to the client device. I have following questions Is the solution tried by me is optimal solution to fix the issue? What other approaches can be tried to fix such type of issue? I would appreciate any suggestions thoughts on this topic. Thank you. |
31 | Unity 5 Networking Send Rate Send Rate is Zero but server movement is still happening I have a client server scenario, just a player moving about on the client and he moves about on the server using the built in networking provided in Unity 5. I have my client scene running in the editor and was playing about with the Network Transform Script Values, more specifically the Network Send Rate. Setting this Value to 29 (its highest) the movement on the server is almost smooth. Setting this value to 1 and the movement on the server is very laggy as I expected. However, if I set the network send rate to 0 on the client, I expected it not to move at all on the server, but it moves and alot smoother than the value 29. Why is it, that when the network send rate is set to 0 that my character still moves on the server? |
31 | udp over cellular networks? I'm starting to build a multiplayer iOS game using UDP. I want the game to be playable over cellular networks, but I can't really find that much information on it. Many people say that it's dependent on your carrier whether or not it will work. I tried searching but I can't really find much info on this topic. I know carriers must allow UDP because of things like video streaming, but what about custom game protocols? Will UDP work over a cellular network? If anyone has a definitive answer or can point me to some resources that'd be great |
31 | How do network applications get around firewalls? Forgive me if this comes off as naive I've only a cursory understanding of network communications. My work has a public and very restrictive network (they appear to block everything that isn't approved) and yet I've seen people accessing many games (World of Warcraft for example). I don't imagine that the network admins made any explicit exceptions for these applications but when I tried to develop a networked prototype with services like 'Photon Server' or 'Adobe's RTMFP' they all fail from the office due to the network restrictions (can't establish connection). Is there some kind of work around that applications like WoW employ that distinguish them from an anonymous networked app I've built myself? (Some kind of fallback channel maybe?) I appreciate that there might not be enough information here for an answer, but any insights would be welcome. Thank you! |
31 | How can I implement a game locator or proxy server? I have a turn based strategy game which already has a multiplayer server client layer that works fine on local network (where one server is set up and players connect to it). I would like to extend this architecture to allow players to play via Internet, but I don't want to have a dedicated game server for that, especially due to performance issues. The game's AI is runs on the game server of course, and multiple games with computer players would "kill" the machine. I would like to have some kind of "central connection point" server that does not run the game logic, state or AI but can be used by players to find servers hosted by other players. How can I implement this? |
31 | What is the impact of many AI enemies on state replication networking? Imagine an online coop style FPS or TDS game where say 2 6 real players fought large amounts (20 60 concurrent) of AI enemies. Could this style of game be reasonably networked over the internet using a Quake or Tribes style partial state replication model? Almost every coop game I know of uses a lockstep style networking in these cases (even games like Halo which use state replication for normal multiplayer, but lockstep for coop firefight). My concern is that the network download (for clients) and upload (for server) overhead of each AI would end up being about the same as if a real player was in the game. Is this a real concern? Or is the limiting factor on the number of players more about how much data the players upload? TLDR Can large numbers of AIs be reasonably networked to a few players with a partial state replication model or is lockstep the only real solution. Any help here would be great! |
31 | How to make my multiplayer Air Hockey better? I've made simple multiplayer web game but don't like how it works. Here's a video example (captured at 85 avg ping) showing what I have. What I used Super naive client prediction called so because there is no reconciliation most of the time players' strikers can't be moved by anything except players themselves Interpolation (it's turned off on the attached video because at the current state of the game in combination with prediction it made things look worse. Without prediction input lag is unacceptably big) I've read some valve wiki articles, Gambetta's articles and some other not so popular sources, which helped to understand general ideas, but I still lack understanding on how to combine various techniques of minimizing delays for players and some implementation details. So here are the questions What is the best way to sync time on client and server and when to start clocks? I should measure average ping and then what? Server sends notifications to clients 'start clocking in X ms' based on ping? Should they even start clocking at the same time? How to improve user experience for my game? I guess I should probably use extrapolation for puck Is interpolation even needed with 60 tickrate for anything with 60 or lower hz screens? I'm not aiming at e sports level experience and would rather make it feel nicer for 60 hz phone screens |
31 | Is there a pattern for writing a turn based server communicating with n clients over sockets? I'm working on a generic game server that manages games for an arbitrary number of TCP socket networked clients playing a game. I have a 'design' hacked together with duct tape that is working, but seems both fragile and inflexible. Is there a well established pattern for how to write client server communication that is robust and flexible? (If not, how would you improve what I have below?) Roughly I have this While setting up a game the server has one thread for each player socket handling synchronous requests from a client and responses from the server. Once the game is going, however, all threads except for one sleep, and that thread cycles through all players one at a time communicating about their move (in reversed request response). Here's a diagram of what I have currently click for larger readable version, or 66kB PDF. Problems It requires players to respond exactly in turn with exactly the right message. (I suppose I could let each player respond with random crap and only move on once they give me a valid move.) It does not allow players to talk to the server unless it's their turn. (I could have the server send them update about other players, but not process an asynchronous request.) Final requirements Performance is not paramount. This will mostly be used for non realtime games, and mostly for pitting AIs against each other, not twitchy humans. The game play will always be turn based (even if at a very high resolution). Each player always gets one move processed before all other players get a turn. The implementation of the server happens to be in Ruby, if that makes a difference. |
31 | Client Server Multiplayer Project I have reviewed the relevant WinForms XNA samples here and here. However, my requirements are slightly different. Given the following I am developing a multiplayer (Client Server) game There will be three projects in the solution, one for Client and Server respectively, plus an additional one containing the core game engine The instances will share common code from this engine project (core Game Engine functionality) I require the Server instance to also allow management of the server (e.g. connection list etc.) via a Windows Form Finally, and importantly, I am proposing to use the Dependency Injection pattern on initialisation of the client server instances to inject the relevant network management class as required similar to the approach here What is the best way to achieve this? Specifically, are there any flaws with organising the projects in the solution the way I have proposed above? For the Server project, do I start it as an XNA project and then call the Winform, or vice versa? Thank you for any advice you can spare. Edit a brief example of the "dependency injection" style pattern I plan to use. Forgive me if this is not an example of "pure" full traditional DI! Create the server using (var game new ExampleGame(new ServerNetworkManager())) game.Run() Create the client using (var game new ExampleGame(new ClientNetworkManager())) game.Run() |
31 | How do I avoid users hacking my network games from the client side? I've decided to make an online game the server sends packets of information to the client application, which is going to simulate what it gets from the server. The client makes a part of the design of the game, and sends the new state back to the server for processing. The clients can send fake information to the server, and inform the server that I've done the task successfully, without trying. Assume a Counter Strike game the client may send a fake packet to the server and tell the server that I've defeated someone. How can I avoid this violation? |
31 | What is better? Lots of small TCP packets, or one long one? I am sending quite a bit of data to and from a server, for a game I'm making. I currently send location data like this sendToClient((("UID " cl.uid " x " cl.x))) sendToClient((("UID " cl.uid " y " cl.y))) sendToClient((("UID " cl.uid " z " cl.z))) Obviously it is sending the respective X, Y, and Z values. Would it be more efficient to send data like this? sendToClient((("UID " cl.uid " " cl.x " " cl.y " " cl.z))) |
31 | NavMesh LoS and "Containing" For a gameserver backend, I have a navmesh for "walkable" areas in form of points triangles. Now I want to check every gametick if the client is still in a legit place and if he shots casts a spell, if his target is in line of sight. I found several possibilities, but I am not sure what is performance wise ideal. To check if the player is still in the allowed area (and not wallhacking) I would check if his position is in one of the triangles with a algorithm using barycentric coordinates like this https github.com SebLague Gamedev Maths blob master PointInTriangle.cs But this would mean that every gametick I have to check soooo much triangles. To check if its LoS I could either check if the line from the player to its target crosses one of the "border" lines of the mesh (which have no other triangle next to it). Those border lines could be computed at bake time and are just a static list for each level. But still it would be a lot lines per check. Second option I found would be to start a Simple Stupid Funnel Algorithm (http digestingduck.blogspot.com 2010 03 simple stupid funnel algorithm.html) until LoS is broken. The questions now are How does a good gameserver handle this can it be optimised? What way to check is the best fastest? Is it common to only check if the position is legit every now and then or every gametick? The Levels are fairly simple ( 300 mesh triangles, 200 border lines, 10 players, 10 npcs maybe) |
31 | Networking How does server fixed timestep work? I'm making a server client model for a top down 2d shooter. Because I need to calculate collisions with walls amp other players using a small delta, I want to use the fixed timestep model like in this example https gafferongames.com post fix your timestep . Apparently this is a common approach for network games. Right now my model looks something like this Client connects and is synced to the current server tick (let's say tick is 50) Client sends its first input the time pressed (local tick 50) to the server Server receives the message at tick 55. Because the message was for tick 50 which has passed, this request is ignored. As I understand it, the client and server run at the same rate, but because of latency the client sends messages too late and all get ignored. Am I supposed to let the server run a few ticks behind the client somehow? How do I resolve this? EDIT No, this is not a duplicate of that question. What OP is asking in his topic is how to account for lag visually from other players. The answer is mostly you can't, but you can smooth it out with entity interpolation. My dilemma is that I can't figure out how to process inputs at all server side using a fixed timestep model. I assume the client sends timestamps which are processed when the server reaches that same frame, but if client server are always frame synced, that means all messages are from the past and are ignored. If I allowed the server to accept a past input anyway it would have to implement it immediately instead of the original frame it was meant for, which would result in inaccuracy. I'll make it real clear If a client sends an input at tick 4 but it reaches the server at tick 7, how does the server go back and process an input meant for tick 4? |
31 | Should I ping for a TCP based game? I have a head to head game where two players communicate through a server based on TCP. I am planning to implement a ping pong mechanism in order to detect network disconnection situations. For example, A pings B every 500ms. If A receives no response from B, A shall consider B is disconnected. If A receives no response from the server, A shall consider A is disconnected itself. Do you think this ping pong system is needed or other method is recommended? |
31 | How to hide a MMORPG backend server from the internet? I want to create a network where the main servers IP is never exposed to the client. By going throught tunnels. Here is a sample http dl.dropbox.com u 12304631 eliteots mc network.jpg Problem By making tunnels through dedicated servers I hope to solve latency issues from some clients that are far away from the main server. But even if this does not succeed, I wish to hide my main server to avoid network attacks directly against it. So the main server only communicates with the tunnel hosts, which then communicates with the clients. So by creating several tunnels I will be able to let customers easily access the main server by switching tunnel if their preferred tunnel is currently under attack. This is not my problem, should be easy to program, however the network configurations between tunnel and main server is the issue because of my lack of experience in this area. Requirements I am not talking about a simple http proxy, I want this to solution to operate on all ports. Or at least the configured ports. Only transmitting TCP. I do not wish any encryption on the traffic between the vpn and main server, I think it should be as fast as possible. I am working on an MMORPG, which is why I put so much effort into learning this. The worst thing that can happen to a customer is to be kicked from game server unable to login to finish their needs. I only operate in an linux environment server based. (Debian Ubuntu). Solution idea I heard having an openVPN server might be what I need. But I have problems operating it, I find it quite complex. First off, I want to know, is this even possible in OpenVPN? If so, how should I configure the network logics? I am open to try out any free solutions you may find recommend me! |
31 | Tips for communication between JS browser game and node.js server? I am tinkering around with some simple Canvas based cave flyer game and I would like to make it multiplayer eventually. The plan is to use Node.js on the server side. The data sent over would consists of position of each player, direction, velocity and such. The player movements are simple force physics, so I should be able to extrapolate movements before next update from server. Any tips or best practices on the communications side? I guess web sockets are the way to go. Should I send information in every pass of the game loop or with specified intervals? Also, I don't mind if it doesn't work with older browsers. |
31 | Character appearance synchronization in open world multiplayer game I am working on a multiplayer open world game where you can equip handhelds and armor pieces. In my architecture, there are clients and an authoritative server. Every equipable item is crafted by a user. They can be different in shape, so it's important that I synchronize shape information. This is expensive data to send (basically an outline plus some more info). Together with this, I also want to synchronize any equipment event that occurs, so when a user meets another user, they can see each other's gear. The easiest solution I've found is to force send gear on equipment, but it will use bandwidth even when two players are far away. This feels like a problem that has been solved a thousand times, so I don't want to reinvent the wheel. Do you know of any best practice known strategy that suits my situation? |
31 | How do I make a turn based game for two players who play with different devices on iOS? I only have experience in physics based games in cocos2d. I want to develop a turn based game in Cocoa Touch (iOS). Two players will play this game on different devices which connect via Bluetooth or Game Center. I'd like to know how to synchronise two devices through a Bluetooth connection. Please tell me of any blog tutorial, guide, or sample code which will help. |
31 | Game clock Synchronization in python I am working on a network game project in python which we want to keep synchronized. I would assume we should use Network Time Protocol to cater for different levels of lag. That being the case, is there an implementation for Network Time Protocol in python? |
31 | MMO Client Server Spoofing Vulnerabilities Ive created a working authoritative client server system using LiteNetLib for my game however im wondering if packet sniffing modification is a real worry i should be developing for. I read some information that other Client sniffing the packets of another client is pretty much impossible since the packets are routed through their ISP. Therefore should i only worry about the client causing problems for the server, instead of also worrying about clients causing problems for other clients? Currently im encrypting every packet sent by the client including movement commands such as 'move left'. My idea is that this will make packet sniffing fail, packet modification fail, and packet spoofing fail. If i remove my encryption doesn't that mean someone can spoof a packet by changing the packet source in the header? (thus sending game commands for another client moving another player!). Usually when its encrypted i know that only the client with the secret key could have sent it, thus validating the packet source. I see everyone saying that people shouldn't encrypt general traffic like this, but whats the truth here! Whats the best way? |
31 | Why do games have different ports for different maps? A little old example for that would be Metin2, this is the only game I know which have that, but there may be more. In Metin2 there are maps which are accessable through other ports. I'm not a network specialist, but I think then it is needed to connect to an other port on an map change. So would it not be possible todo all that on one port? Are there any benefits from that? Could it be that there is a limit on port connections on a server, that this would be something for loadbalancing? |
31 | Why do games use tick rates in their networking and servers instead of an event system? Why do most games limit themselves with a tick rate in their networking? Isn't it better to make something like an even system where for example client A does something then the client sends related info to the server, and same for the server when something happens on it it sends a packet to the client, instead of using a tick rate and sending information only at some specific frequency. Is it cheaper faster to send more data in a single packet or? And the same question goes for server tick rates, some servers limit themselves on specific tick rate frequencies, why do they do that? Why not just make a loop and run each tick after each other instead of having a gap between them or risking one tick to take longer than it should and causing bugs? What's the benefit of the tick rate approach for servers and for networking? |
31 | game server client user input event handling I'm currently getting my feet wet in the realm of networking, so I set a goal to make a simple client server game using SFML for both graphics and networking. In my head it seemed easy at first, but the more I got into it the more questions arised. I didn't want to make a post before I hadn't done any research, but now, having read many blog posts and articles, there's nothing to lose. The game I'm working on is a trivial PONG game server waits for 2 players, when they are connected, clients send server paddle's X position only if mouse is moved. Server reads in the X pos. and sends each client opponent's position. The problematic part is opponent's behaviour on the client side. When playing both clients server on my computer, using 100 CPU speed server side, the opponent moves smooth, but having CPU running as fast as it can is nonsense! If I reduce update speed the movement becomes weird so to say. Might there be anything to do with client side prediction (I read about it too, but didn't quite grasp how it would be implemented)? Since there are frequent position changes, should the server's update speed be as high as possible? I'm using TCP, which I understand is "reliable" no lost packets. For such fast paced game like PONG, which protocol is more suitable. Now, I do not fully understand the magic behind it all, very very thrilled about network programming. I've never been more excited during programming as I am dealing with networking. Thank you for your attention! |
31 | Game Maker picking the wrong network adapter for broadcast In my game I need to get the local network IP of the computer that is running the game, and for that purpose I have the following code Create event randomize() var random port irandom range(49152,65535) host network create server(network socket udp, random port, 5) if ( host lt 0 ) show message("Failed to create a broadcast server") game end() else var tsock network create socket(network socket udp) var tbuff buffer create(32, buffer fixed, 1) buffer fill(tbuff, 0, buffer bool, 0, 32) network send broadcast(tsock, random port, tbuff, buffer get size(tbuff)) network destroy(tsock) buffer delete(tbuff) Async network event global.game ip string(async load ? "ip" ) instance destroy() I've manually set up my local network IP to be 192.168.1.150, but when I run the code above, I get the IP 169.254.51.115. Because I wasn't expecting such IP, I ran the ipconfig all command (on Windows) and I got the following output (I've translated the output because my computer is in another language, and I've deleted the information that isn't relevant to this) Ethernet adapter Specific dns for this connection. . Home Description . . . . . . . . . . . . . . . Realtek PCIe GBE Family Controller ... IPv4 address. . . . . . . . . . . . . . 192.168.1.150(Preferred) Subnet Mask . . . . . . . . . . . . 255.255.255.0 Default gateway . . . . . 192.168.1.1 DHCP server . . . . . . . . . . . . . . 192.168.1.1 DNS Servers. . . . . . . . . . . . . . fe80 1 13 1.1.1.1 1.0.0.1 Ethernet Npcap Loopback Adapter Specific dns for this connection. . Description . . . . . . . . . . . . . . . Npcap Loopback Adapter IPv4 automatic configuration address 169.254.51.115(Preferred) Subnet mask . . . . . . . . . . . . 255.255.0.0 Default gateway . . . . . DNS Servers. . . . . . . . . . . . . . fec0 0 0 ffff 1 1 fec0 0 0 ffff 2 1 fec0 0 0 ffff 3 1 So, from my understanding point of view, Game Maker is getting the Ethernet Npcap Loopback Adapter instead of the regular ethernet adapter. I could delete the Npcap Loopback adapter, but what if a user has wifi and ethernet connection? Is there a way for Game Maker to choose one or another adapter? In case the previous answer is no, is there a workaround for this to avoid getting the Npcap loopback adatper? |
31 | Turn based card game multiplayer http polling or TCP I am working on card games for mobile devices. For multiplayer I will be communicating through a central server. For the purpose I sorted out three options HTTP polling TCP Websocket (client libraries are not good, so will not use it) HTTP polling is simple, but I fear it will introduce much more delay and too many HTTP calls. TCP introduces other complications. So my question is Is HTTP polling appropriate for a card game? Will the HTTP overhead be too much? How much interval should I keep for polling? Can you give a sample game based on HTTP polling? |
31 | Executing commands at the exact same time on 2 or more computers I have an RTS game, with deterministic simulation, but if I want multiplayer to actually work, I need commands sent between computers to be executed at the exact same time. My game's networking is just sending commands between the players' computers, and the simulator executes the commands in order, which, hopefully, will result in each player seeing the exact same game. However, if the commands aren't executed at the EXACT same time, then the simulation will become out of step and everything will be wrong. How could I do this, and are there other ways to make sure everything is in sync? |
31 | Sending changes to a terrain heightmap over UDP This is a more conceptual, thinking out loud question than a technical one. I have a 3D heightmapped terrain as part of a multiplayer RTS that I would like to terraform over a network. The terraforming will be done by units within the gameworld the player will paint a "target heightmap" that they'd like the current terrain to resemble and units will deform towards that on their own (a la Perimeter). Given my terrain is 257x257 vertices, the naive approach of sending heights when they change will flood the bandwidth very quickly updating a quarter of the terrain every second will hit 66kB s. This is clearly way too much. My next thought was to move to a brush based system, where you send e.g. the centre of a circle, its radius, and some function defining the influence of the brush from the centre going outwards. But even with reliable UDP the "start" and "stop" messages could still be delayed. I guess I could compare timestamps and compensate for this, although it'd likely mean that clients would deform verts too much on their local simulations and then have to smooth them back to the correct heights. I could also send absolute vert heights in the "start" and "stop" messages to guarantee correct data on the clients. Alternatively I could treat brushes in a similar way to units, and do the standard position velocity client side prediction jazz on them, with the added stipulation that they deform terrain within a certain radius around them. The server could then intermittently do a pass and send (a subset of) recently updated verts to clients as and when there's bandwidth to spare. Any other suggestions, or indications that I'm on the right (or wrong!) track with any of these ideas would be greatly appreciated. |
31 | Adding multiplayer to an HTML5 game I am interested in making a game that I currently have a co op experience, however I'm curious as to the best method of implementing this in HTML5. I have made games before using straight C sockets, and also with the Net library for SDL. What are some of my best options for doing this in a canvas based environment? At present, all I can come up with are either AJAX database solutions (with a high refresh rate), or somehow implementing a PHP server that would funnel the data through sockets. The overall gameplay would be a 2.5D platformer ish type of game, so both clients would need to be continually updated with player positions, enemy positions, projectiles, environmental data, etc. |
31 | Which game logic should run when doing prediction for PNP state updates We are writing a multiplayer game, where each game client (player) is responsible for sending state updates regarding its "owned" objects to other players. Each message that arrives to other (remote) clients is processed as such Figure out when the message was sent. Create a diff between NOW and that time. Run game specific logic to bring the received state to "current" time. I am wondering which sort of logic should execute as part of step 3 ? Our game is composed of a physical update (position, speed, acceleration, etc) and many other components that can update an object's state and occur regularly (locally). There's a trade off here Getting the new state quickly or remaining "faithful" to the true state representation and executing the whole thing to predict the "true" state when receiving state updates from remote clients. Which one is recommended to be used? and why? |
31 | Does it make sense to use both TCP and UDP at once? After reading Is UDP still better than TCP for data heavy realtime games?, I'm wondering if it makes sense to use both TCP and UDP at the same time, but for different things TCP for sending information that is sent infrequently, but should be guaranteed to arrive reliably. Such as score updates, a player's name, or even the on off state of a light in the game world. UDP for transmitting information that is updated constantly and can be lost occasionally, since newer information is always on the way. Such as position, rotation, etc. Is this a reasonable idea? What are the possible drawbacks? Are there better ways to handle this? |
31 | NavMesh LoS and "Containing" For a gameserver backend, I have a navmesh for "walkable" areas in form of points triangles. Now I want to check every gametick if the client is still in a legit place and if he shots casts a spell, if his target is in line of sight. I found several possibilities, but I am not sure what is performance wise ideal. To check if the player is still in the allowed area (and not wallhacking) I would check if his position is in one of the triangles with a algorithm using barycentric coordinates like this https github.com SebLague Gamedev Maths blob master PointInTriangle.cs But this would mean that every gametick I have to check soooo much triangles. To check if its LoS I could either check if the line from the player to its target crosses one of the "border" lines of the mesh (which have no other triangle next to it). Those border lines could be computed at bake time and are just a static list for each level. But still it would be a lot lines per check. Second option I found would be to start a Simple Stupid Funnel Algorithm (http digestingduck.blogspot.com 2010 03 simple stupid funnel algorithm.html) until LoS is broken. The questions now are How does a good gameserver handle this can it be optimised? What way to check is the best fastest? Is it common to only check if the position is legit every now and then or every gametick? The Levels are fairly simple ( 300 mesh triangles, 200 border lines, 10 players, 10 npcs maybe) |
31 | Client and server loops don't match up I'm trying to build a small networked game using WebGL and NodeJS. I have a basic client and server setup and I'm at the point where I'm trying to implement dead reckoning to simulate what happens on the client. I have a odd problem which I'm not really sure how to fix, the game loops for my client and server don't seem to match up and the client one always seems to be faster. I'm hosting my server on the same system as my client right now and I'm logging every frame for the two. If I log it for longer than 5seconds the server starts to get behind by 10 20 frames and the gap just gets bigger and bigger over time. There isn't really anymore processing that is happening on the server than on the client at the moment because I'm working with a really basic example right now. My loop for both right now look something like this var loopDelay 16.666666666666666666666666666667 function loop() setTimeout(function() update() loop() , loopDelay) On the client I did have something like this function loop() setTimeout(function() update() requestAnimationFrame(loop) draw() , loopDelay) But I removed it and copied the server one temporarily when I started running into this problem to make sure it wasn't that. What can I do to make the two sync up perfectly? Thanks |
31 | Movement networking for a Worms like game I want to implement a strategy artillery game, similar to Worms Arcanists. As game development (and game networking especially) is new to me, I was wondering whether this would be a good performant way to do the movement networking Server has all client's positions. Moving client to server Message start moving, moving direction Server now starts a simulation of the moving client moving. Server to all clients, except originating one, every 100ms(?) Message set client position client id, new position new position calculated by the server's simulation Clients lerp the moving client's position. Moving client to server Message stop moving server's simulation ends Server to all clients, including originating one Message set client position client id, final position all clients have the same position for the moving client in the end |
31 | In a 2D multiplayer game should I send the position of user to the server all the time? In a 2D game where the user moves with the keyboard arrows, should the user send all the time he moves his position (x, y)?. If the user has some speed, the user would send (x, y) like 50 times pixel by pixel in just a second. |
31 | Implementing game synchronization between clients and server I'm creating a small online multiplayer game where I have multiple thin clients and an authoritative server. Both the client and the server have a fixed game loop. Now I have a game entity with the following properties X position float Y position float Direction float In the client, the entity is in constant velocity changing its direction based on user input and sends an input event to the server. LEFT, PRESSED Entity moves to the left LEFT, RELEASED Entity moves to the right Every event is queued on the server, and simulated the same way as on the client (calculating the new properties based on trigonometric functions) and the event is send to other players in the room. The other players apply the same simulation to that particular entity (keeping track of what key is pressed for each entity). Now after some time playing, the position and direction start to drift and stop being in sync. I suspect this has to do with floating point arithmetic(?) Is this implementation correct, rather than sending its position and direction every step? How would I solve this problem? I think I need to make the server the single source of truth and send regular state snapshots to the the clients to correct possible mistakes drifting? What would be a good interval to keep the clients up to date? At the moment, I'm broadcasting an event to every player in the room. What would be a nice approach to only send events to players near the entity? Would a quadtree work here (the same I'm using for my collision detection)? |
31 | Handling packet impersonating in client server model online game I am designing a server client model game library engine. How do I, and should I even bother to handle frequent update packet possible impersonating? In my current design anyone could copy a packet from someone else and modify it to execute any non critical action for another client. I am currently compressing all datagrams so that adds just a tad of security. Edit One way I thought about was to send a unique "key" to the verified client every x time and then the client has to add that to all of it's update packets until a new key is sent. Edit2 I should have mentioned that I am not concerned about whether the actions described in the packet are available to the client at the time, this is all checked by the server which I thought was obvious. I am only concerned about someone sending packets for another client. |
31 | How do I efficiently send RTS unit selections over the network? I have a multiplayer RTS game with every unit assigned an ID. How can I efficiently send across a network the units selected by a player? For example, Starcraft 2 has upwards of 200 units per player and each player can select a maximum of 255 units at a time. How can I implement such a system with reasonably low response time and bandwidth? Should I bother sending IDs? Should I perhaps send a bitmask with each bit defining whether each unit is selected? |
31 | How can I detect disconnected clients in a peer to peer network of this topology? I'm working on my first multiplayer game (RTS genre) and for the networking model, I'm leaning more towards a peer to peer model as opposed to a client server model. I want my game to be able to handle a large number of users concurrently (around 50 100 users) in a reasonable manner. I've come up with a proof of concept that can achieve moderate speed and moderate load balancing across the network. For it to work, one of the peers has to be designated as a central authority (i.e. the host). The host then receives updates from users through a star topology and then broadcasts the changes to other users through a tree topology, as below This type of network has one big problem churn. I'm having trouble figuring out how to deal with users that disconnect from the network. If nothing is done for them, all of that user's children (and descendants) will lose connection. How can I detect disconnected nodes in a peer to peer network of my expected size and remove them without harming the other, still connected clients and without placing undue load on the designated host? |
Subsets and Splits