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 AtomicMarine · Jun 24, 2013 at 12:21 PM · networkingmultiplayerairandom gen

Lets talk multiplayer: General Questions?

So as it stands I've spent a lot of time creating a primarily single player experience.

However the experience would suit itself to being multiplayer quite well, before now I haven't had the skills to implement somethings so ambitious however for now I would like to try. I have a few questions on networking.

So far I have been able to have multiple players playing in a server generated random gen map with independent movement, and player control.

I have run into some stumbling blocks.

my biggest question is:

tl;dr HOW does one run an update script of an AI on a network so that the AI behaves the same on all computers??

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
1
Best Answer

Answer by Em3rgency · Jun 24, 2013 at 12:29 PM

Have the server do the AI calculations and send the players the results. All results will be the same.

For a slightly more advanced implementation, to reduce lag issues, have the scripts also run on the players side, but all the player-side objects or actions or whatever should be temporary, that get destroyed/revoked after either receiving the confirmation from the server or if a certain amount of time has elapsed.

In general it is accepted that the server handles(or at least confirms) all logic calculations. You can't have the client do calculations and then just send them out to everyone, because a cheater might rig his client to his advantage, and if there is no server verification on the calculations, he'll get away with it.

Comment
Add comment · 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
2

Answer by Jamora · Jun 24, 2013 at 12:33 PM

You only need to run the AI update on one computer, then transfer the effects to the other computers. The following is how I made a very basic multiplayer top-down shooter AI:

NetworkInstantiate AI mobs from the server. Have clients remove the AI scripts. The NetworkView on AI mobs observes the transform ( so only the position of mobs is updated on clients ). Whenever an AI mob shot, the server calculated if anyone got hit and how much hp they lost. Then the server called an RPC on all machines to update their values accordinly.

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 AtomicMarine · Jun 24, 2013 at 01:39 PM 0
Share

Thank you, this was very helpful. I too am building a top down shooter, so its the same thing :P I will try what you said.

avatar image Laaevin · Nov 25, 2013 at 07:40 PM 0
Share

How do you have the clients remove the AI scripts?

avatar image Jamora · Nov 26, 2013 at 02:27 PM 1
Share

You can use the OnNetworkInstantiate callback.

The code could look something like:

 void OnNetworkInstantiate((Network$$anonymous$$essageInfo info){
     if(!networkView.is$$anonymous$$ine){
         Destroy(gameObject.GetComponent<AIScript>());
     }
 }

avatar image Laaevin · Nov 26, 2013 at 03:05 PM 0
Share

Perfect, thank you! I wish I had enough rep to up vote your answer!

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

18 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

Related Questions

Unity networking tutorial? 6 Answers

See the opponents card only when dropped on the board (Unity Networking) 0 Answers

View PvP scores on screen in real-time 1 Answer

GameObject not destroyed on Collision on Standalone - multi 0 Answers

How do we use a game manager with Unity networking? 0 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