Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Chapi · Sep 23, 2014 at 06:35 PM · multiplayerrts

RTS Multiplayer Model

Lately I've been trying to develop a RTS Multiplayer based game and I've read some stuff about how Age of empires multiplayer was done and some models of mutliplayer game and I'm quite worried if my model will work.

My idea was to have all the players host an instance of the game as client mode and the one hosting run two instances of the game, one as client like the others and one as server.

The server instance would receive all the commands or actions executed by the players and run the simulations (Like pathfinding, moving a unit, making a unit attack) and at the same time tell all the clients the coordinates (the state of the transform component) of all the units at all times, so basically only the server had the authority to move stuff around and the clients would only be able to see where the units are and select them to give them orders which are sent to the server and the server executes them.

At first I thought it would be a good model but then I realized it's very bandwidth consuming and I'm not sure if it would work. Since it's a RTS there could be 1000 units moving at the same time, meaning the server would be needing to send the position of 1000 the amount of clients connected (Maximum 8 players) and the corresponding action they are performing in order to predict the animation. So it would be 1000 Vector3s 8 times + a int of the action ID * 8, approx 32000 values per frame, meaning if server is running at 90 FPS we would have 2,880,000 values per second. Sounds like a great number to me but assuming we have a 1MBps minimum requirement bandwidth to play the game, would it be way too much data to be sent, or would it work?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by MaxSmalls · Oct 02, 2014 at 05:11 AM

The technique used in most modern RTS is called Fixed Lock Step and sometimes Deterministic Lockstep. It's a bit harder to do in managed languages such as Mono/C# which Unity uses but can be done. Here's a link to a tutorial and sample set of code that someone already did in Unity: http://clintonbrennan.com/2013/12/lockstep-implementation-in-unity3d/

If you want a general overview of the history of networking models, this is a good place to start. http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

I also recommend the other information here too as it is relavent and gets pretty in depth on the problems associated with both networking and physics... or even worse trying to have networked deterministic physics!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Chapi · Oct 08, 2014 at 03:09 PM 0
Share

Sorry I took so long to read your answer, but thank you so much! This was exactly what I was looking for, a website or someone explaining in depth how networking really works and the ways to accomplish it. I've seen the lock step tutorial already but I didn't really like the idea of how it works so me and my $$anonymous$$m decided to reuse our code and switch to a different type of game, but that's another story. And right now I'm reading the article about networking in games and it's super interesting, been looking for one like this but couldn't find, thanks so much again!

avatar image MaxSmalls · Oct 09, 2014 at 03:14 AM 0
Share

No problem! Glad I was able to help!

avatar image
0

Answer by Kiwasi · Sep 23, 2014 at 07:43 PM

1 MBps strikes me as very high. You'll hit a GB of data in about 20 minutes. My entire monthly bandwidth would be gone after playing you game for 24 hours. (You may laugh, but capped internet is still a reality in many parts of the world.) Even on an unlimited plan my ISP provider would probably throttle speeds.

Ever wonder why Age of Empires had that annoying population limit?

Sending the position every frame is probably not needed for an RTS. You could send a current position and a target position a couple of times a second. Have the individual clients interpolate to figure out what happens in between.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Chapi · Sep 23, 2014 at 08:05 PM 0
Share

Thanks for the answer!

Yeah I've though about what you said of somehow letting the clients run the simulation but not entirely, meaning the server will make them run small simulations every maybe 1 or 2 seconds so there's less probability of desyncing. And yeah age of empires (even AoE 2) can handle up to 1600 units per match, a very large amount but AoE uses lockstep networking which I kinda find annoying to code. It basically syncs every players game and runs game logic and simulations once per gameupdate ins$$anonymous$$d of once per frame, and it syncs the gameupdate across all the players and blah blah blah. It is a good system for networking but not exactly what I'm looking for since it seems like a pain to code everything in relation to that gameupdate.

Do you know of any other models or tutorials for networking on a RTS game?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using Unity Navigation in a fixed timestep 1 Answer

Multiplayer RTS Script 2 Answers

Multiplayer RTS: Rendering a specific mesh for multiple cameras 0 Answers

Photon PUN 2 RTS one time information sharing 0 Answers

Unity networking tutorial? 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges