I'm working on highly comptative fast paced momentum based multiplayer 2D game, meaning that the game state is pretty carousal, first i thought about syncing player inputs, meaning that the server receive inputs from a player and sends back to (the same lobby players) and then the players calculate everything related to that player's input and apply it locally, animations, velocity, impulse etc..., This ensures consistency but is seems to be having a huge latency drow back since it's a reliable connection and the player waits for the server to confirm his input, client side prediction isn't an option since I'm not doing any server side calculation to do reconcilation also that messing a single input might mess up the game state or is it ? I'm not experienced enough to say so, I'm just wondering if this is a viable approach or i should just sync the game state unreliably with interpolation/extrapolation mechanics (i did but my game doesn't feel smooth probably because I'm syncing the position and rotation in a physic based game ?), If syncing the game state is much viable approach how can i make it as smooth as possible in a physics based game, what exactly should i be syncing?
Hi,
my best approach so far was to send the DirectBodyState of the physics object in an interval and whenever a collision has happend but only if the body is not sleeping. The DirectBodyState can then be injected in the remote object by the client. The remote object will then extrapolate the physics-state from there on. This is mostly reliable but needs serious tweeking for a flawless experience.
A client may initiate a physics interaction (collision) but should then let the server "master" the object.
So the client send a DirectBodyState after the player-object made a collision but all collision with the environment should be handled by the server.
I hope you understand what i mean
Most games solve this with interpolation. You wouldn't be syncing the inputs themselves but the local/remote state.
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
Syncing player inputs won't work unfortunately, since most simulations, especially physics engines, are not deterministic so the same set of inputs isn't guaranteed to create the same results. It is not entirely impossible to create a deterministic simulation, but it has some drawbacks and it is so complex that it is almost never done.
If you want the game to be fast paced and real time, you really don't have a better option than to use prediction on the client. You can do it in a peer-to-peer setup by having one of the players act as the authoritative server. Of course the downside of that is, that the host player will most likely have a significant advantage.
Also you mention reliable connection, if you are referring to TCP that's really not good enough for fast paced action games and you will want to switch to UDP eventually (which will also require handling dropped packages).
None of this is trivial, but there is a ton of information out there if you really want to dig into it. You can definitely do it if you are determined, just don't expect it to be easy or quick if this is all new to you.
The easy way out would be to find a high level abstraction that fits your need, or a template project that does it well. Since I am new to Godot myself, I don't know what is available in this regard. Doing it yourself is a lot more satisfying though and the knowledge you acquire from doing so will be useful forever.
Seems that i should've kept simple and just synced the game state, thnx guys really appreciated :')
© 2022 - 2024 — McMap. All rights reserved.