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 /
  • Help Room /
avatar image
0
Question by TarheadJimmy · Sep 07, 2016 at 03:22 PM · unity 5networkingprefabspawning

Problem spawning prefabs client side, stand alone build.

Im trying to make it so that I can start any scene in my project, click a button and a NetworkManager is created and then you either join, or create a game as host. The code I have works perfectly when I run the game from the editor (I can start as both client and host).

The problem starts when I create a stand alone build, I can start as Host without any problems. But when I then try to join as a client I get "Failed to spawn server object, assetId=6c4737d3f84f22c44a4afb89d63ce6d2 netId=2", and nothing is spawned.

Here is the code that works for the Host,

         var go = new GameObject("NetworkManager");
         var netManager = go.AddComponent<NetworkManager>();
         var resources = Resources.FindObjectsOfTypeAll<GameObject>();
         foreach(var res in resources)
         {
             if(res.GetComponent<NetworkIdentity>() != null)
             {
                 ClientScene.RegisterPrefab(res);
             }
         }
         netManager.onlineScene = SceneManager.GetActiveScene().name;
         var conn = netManager.StartHost();


And this is the code for the client:

         var go = new GameObject("NetworkManager");
         var netManager = go.AddComponent<NetworkManager>();
         var resources = Resources.FindObjectsOfTypeAll<GameObject>();
         foreach(var res in resources)
         {
             if(res.GetComponent<NetworkIdentity>() != null)
             {
                 ClientScene.RegisterPrefab(res);
             }
         }
         netManager.onlineScene = SceneManager.GetActiveScene().name;
         if(string.IsNullOrEmpty(ip))
         {
             ip = "127.0.0.1";
         }
         netManager.networkAddress = ip;
         netManager.StartClient();


The code is pretty much the same between the two, the only real diffrence is that we use StartHost as the host and StartClient as client. Im at a complete loss about this...

They only thing I can think would be diffrent is maybe assetID or the netID? But one would think unity would have the same netID & assetID on the same resources Im running the same executable after all..

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

0 Replies

· Add your reply
  • Sort: 

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

128 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Client choice of prefabs on a NetworkLobbyManager 0 Answers

What does this error mean? 1 Answer

NetworkServer.Spawn() only on Server (with registered prefabs) [Unity 5.2.3f1] 0 Answers

since update to 5.5.1f1 i keep getting Network is not active Error 0 Answers

Unet Spawn Prefabs When Scenes Changes 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