- Home /
Multiplayer strategy game advice
Hello folks,
I'm making a 2-5 player real-time strategy game and am looking for general advice on networking. I do not understand it very well and have had to rewrite so much code that I should probably get advice before continuing to dig myself deeper.
I would like some information on specific players stored independently of who is connected or who leaves in the middle of the game. For example, diplomatic relations. Right now, I have a helper object store all of that data and do a Command and subsequent ClientRpc whenever that data is changed by a local player. Is this a good idea or is there some other way?
Each player controls an army. There is some randomness in targeting and such. What calculations should the server handle and what should the clients handle, and what should be synced to/from who? Examples: moving, targeting, shooting. Again, I would like an army to continue to exist if their player disconnects.
If movement is handled by clients and synced, as to my understanding would be best, how should I sync movement commands given by players? If P1 tells their army to go South, and P2 is still calculating them to be moving North, that seems not ideal. Would SyncVar be a good solution?
Any input would be appreciated! Input that doesn't say "go read the documentation" would be appreciated more.
Thanks,
Nomenokes
if you intend to have several players each handling dozens of items, You are really going to need to come up with a creative way to sync your items and positions. So you don't overload your users bandwidth. proficiency in what you are sending is a Big challenge in the type of game you are talking about. Simply syncing all your items every frame is just going to give you a jittery laggy game if it even works at all. Generally speaking you send as little as needed. if your armies are "click to move" then you shouldn't need to update positions every frame. consider sending where the click was and who is moving there ins$$anonymous$$d. if you really need accuracy consider syncing items that are away from other players less often. can you get away with rounding off positions ? floats are much larger to send than ints. If your items general move in strait lines, consider just sending only the direction they are moving when it changes. of course an occasional position needs to be sent at the end of a "path" to keep everything in sync. most of this depends on your game and how big you wanna get. as far as you concerns about a perfect sync, no game is perfect.
Answer by austinsun102 · Nov 06, 2018 at 12:11 AM
This video should help you: https://m.youtube.com/watch?v=-m28axeuRNs&t=578s∈dex=4&list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ
Helpful, but not quite what I was looking for. That is about a simple FPS where each player only controls themselves, whereas I would like each player to control other objects.
Your answer
![](https://koobas.hobune.stream/wayback/20220612181615im_/https://answers.unity.com/themes/thub/images/avi.jpg)