Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 marcelop · Oct 28, 2015 at 01:18 PM · networkingmultiplayerspawnloadleveladditiveasync

UNET: NetworkServer.SpawnObjects() does not spawn objects loaded from Application.LoadLevelAdditiveAsync

Our game loads every scene asynchonously now. I have some objects that have the NetworkIdentity component on them, and they are placed in a scene that I load with Application.LoadLevelAdditiveAsync. After the loading is complete on both the server and the client, I call NetworkServer.SpawnObjects() on the server. However, that does not enable these objects on the client.

Am I doing something wrong? Or was it supposed to 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
1

Answer by seanr · Oct 28, 2015 at 03:26 PM

this is currently not supported. it is on the roadmap though.

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 marcelop · Oct 28, 2015 at 04:13 PM 0
Share

Thanks for the answer @seanr ! Would you know in which version that would be available?

Also, is the problem here the fact that it is additive or asynch? For instance, is SpawnObjects supported for Application.LoadLevelAsync now?

avatar image seanr marcelop · Oct 29, 2015 at 01:38 PM 0
Share

the additive part

avatar image
0

Answer by schaeff · Jul 17, 2017 at 08:34 PM

It's quite an old question, but it's still one of the top ranked on google, when searching for Async loading in Multiplayer games. Also I did not test it with LoadLevelAdditiveAsync since seanr said that it's not working.

First you want to start loading on all clients, so you need an Rpc which in return calls something like this:

   //use this to track the progress of your loading
   public AsyncOperation async{ get; private set; }

   IEnumerator StartLoadingAsync ()
         {
                     // Start the async loading process
             async = SceneManager.LoadSceneAsync ("MyLevel");
                     // make sure the scene won't be changed before you tell it to
             async.allowSceneActivation = false;
     
             //this waits until async is completely done    
             yield return async;
     
             Debug.Log ("Waiting for Async Loading is Done");
     
             async = null;
     
             // the Tell Server that the client finished loading
                    Cmd_IamReady(myNetworkIdentity);
         }

async.progress will stop at 0.9, until you set async.allowSceneActivation = true, so once you reach that point, let the server know. Once all clients are at 0.9, you have to

1) Send an Rpc that sets async.allowSceneActivation = true

2) NetworkServer.SetAllClientsNotReady ()

SetAllClientsNotReady will deactivate that clients receive RPCs, so make sure all important information are sent before that. Your StartLoadingAsync function will now go to its end, where you want to tell the server that you are ready via Cmd_IamReady. This function should call NetworkServer.SetClientReady (clientNetworkIdentity.connectionToClient); on the server.

Once all your clients are ready, call NetworkServer.SpawnObjects() on the server.

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Multiplayer Networking 1 Answer

Unet spawn a camera? 0 Answers

Sequencing Spawning for Multiplayer 1 Answer

Trying to spawn players in multiple starting positions 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