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
0
Question by dyankov · Aug 13, 2014 at 11:44 AM · networkingmultiplayerrpg

Multiplayer in Action RPG, best approach?

Hi,

In the last couple of days I've been reading a lot about multiplayer in Unity and in general. I have an action RPG game that is nearly ready and I'm thinking about adding multiplayer at a later stage post release.

From what I understand there are multiple ways to handle synchronisation of data between the different connected clients. For example, it's pretty obvious that the other human players can be synchronised with NetworkView that automatically syncs position and rotation of an object across clients. But what about the 50 enemies that are using pathfinding and local avoidance? How would you sync the AI across all clients? Does the entire AI logic have to be on the server?

For example, does the server have to determine "spawn enemy there, now go there, now attack this player, now cast a spell on the other player", etc etc.

What's the best approach of an action RPG game?

Comment
Add comment · Show 1
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 Pindwin · Aug 13, 2014 at 03:44 PM 0
Share

too much to write in depth, but what you are looking for is authoritative or semi-authoritative server. Bad news is, networking is not something you simply "add" to existing game without facing multiple problems like the one you have described above. It's much better to think about network architecture as early as possible.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by mediumal · Aug 13, 2014 at 06:13 PM

I am also working on an action RPG with (cooperative) multiplayer support.

The AI logic doesn't necessarily have to all be on the server. RTS games like Starcraft avoid syncing large amounts of enemies by distributing the simulation on each client. However, having each client handle AI individually and end up with the same result requires a deterministic game engine, and that is going to be very hard to achieve in Unity.

Instead I went with having the server control all the AI. The clients only see the end result of the AI via synced rigidbodies and animation states of all enemies. I then use RPCs when enemies want to interact with remote players and vica-versa, for things like damage. It is useful when taking this approach to separate the decision-making code that should only be run by one client with the rendering code that needs to happen on all clients.

Before worrying about the network overhead of 50 enemies just try it. If it ends up being a problem then you can try to optimize it, and if it isn't a problem then you've saved yourself a lot of time over the distributed solution.

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 Lylek · Jan 10, 2015 at 05:14 AM 0
Share

"separate the decision-making code that should only be run by one client with the rendering code that needs to happen on all clients."

Thank you!! :) I had my server ("first") handling everything, for all enemies, and it was lagging like crazy for all other clients. I read this and change all "rendering" (movement, animations) to run through RPCs; keeping the server still making the decisions. Runs perfectly smooth! =)

avatar image
0

Answer by KiraSensei · Aug 13, 2014 at 12:01 PM

For the position of mobs, I don't understand why a network view attached to them would not work as well.

Then for spawning, the server has to know where and when it happens, so if the mob handles itself, it must talk to the server, and then the server will tell all the players where it is, or the server handles the spawning directly, and instantiate the mob threw the network to all players. The pathfinding in my opinion does not have to be handled on the server, only directly by the mob, and then the network view does the job. For the spell casting, the mob handles itself, but has to tell the server what it does, and then the server tells to every player the action.

There should be other possibilities of course, but this one should work !

Comment
Add comment · Show 4 · 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 dyankov · Aug 13, 2014 at 12:10 PM 0
Share

Thanks for the answer. I think a network view attached to each enemy won't work because of the huge network overhead that it would cause. I'm thinking about what would happen if a mob decides two different things on the different clients. For example if the pathfinding and LA is handled locally, on one client the mob might end up close enough to a player for a melee attack, while on the other client it might decided that it should use a ranged attack. That's my main concern of "syncing the AI".

avatar image Pindwin · Aug 13, 2014 at 03:49 PM 0
Share

I can't really see how exactly would you like players to have the same game experience without synchronising mobs, which will require either attaching NetworkView to each mob or writing some custom solution with single object synchronising all mobs, which will be a nigthmare to write, synchronise and manage. If you are so concerned about network overhead, you can flatten Vector3 to 2 ints and send them over network, but I seriously doubt it will make any difference.

avatar image KiraSensei · Aug 13, 2014 at 06:32 PM 0
Share

Why do you think the mobs would decide two different thigs ? Since one decision is sent for all players, everything would work correctly !

avatar image Pindwin · Aug 14, 2014 at 05:34 AM 0
Share

Because its network and character positions are slightly different, "ping behind". And how much they are behind is unpredictable, so the whole thing is non-deter$$anonymous$$istic. If decision is "attack player A", chances are that player A is out of sync, in fact, it will never be in sync unless it stands still.

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

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Client Disconnect with message “Peer Created” - PUN 0 Answers

Multiplayer Problems 1 Answer

Instantiated objects does not appear on clients when connecting 1 Answer

Multiplayer Networking in Unity? 1 Answer


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