• 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 Wolfo · Dec 15, 2015 at 07:02 PM · unity 5networkingnetworkspawnspawning

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

I've been trying to figure this out for more than a month now, I cannot proceed in my game's development due to this error which appeared all of sudden. I have no idea what caused this but now NetworkServer.Spawn() only works on Server while the Client sends an error message (not always)

Spawn scene object not found for -int-

followed by

Did not find target for sync message for -int-

Class which takes care of registering prefabs:

 public class RegisterPrefabs
 {
     public static void Register()
     {
         foreach (GameObject temp_ent in Resources.LoadAll<GameObject>(""))
         {
             if (temp_ent.GetComponent<NetworkIdentity>())
             {
                 ClientScene.RegisterPrefab(temp_ent);
                 Debug.Log(temp_ent + " registered for loading!");
             }
         }
     }
 }

Registering prefabs:

         public override void OnStartLocalPlayer()
         {
             RegisterPrefabs.Register();
         }

Quick method for testing NetworkServer.Spawn():

         public void TestSpawn(Vector2 pos, Quaternion rot)
         {
             Object[] randomWeapon = Resources.LoadAll("Guns/");
             GameObject go = Instantiate(randomWeapon[Random.Range(0, randomWeapon.Length)], pos, rot) as GameObject;
             NetworkServer.Spawn(go);
         }

Any ideas? I desperately need help. I even tried changing connection's main channel (0) to ReliableSequenced (on Host code):

             ConnectionConfig config = new ConnectionConfig();
             config.AddChannel(QosType.ReliableSequenced);
             config.AddChannel(QosType.Unreliable);
             manager.StartHost(config, 8);

But no use. Instead, NetworkServer.Destroy() seems to be working just fine on Objects the scene comes with. Every GameObject has its own NetworkIdentity (and NetworkTransport), no Server Only, no Client Auth(although I tried with, no change)

Comment
Add comment · Show 2
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 clever · Oct 14, 2016 at 04:31 AM 0
Share

Having similar issue with objects spawning on server but not client despite making sure everything is correct. Did you end up solving this?

avatar image Wolfo clever · Oct 14, 2016 at 08:52 AM 0
Share

Argh, I'm sorry buddy it's been so long I don't remember how I did it but here's a few things I can tell you to check:

  1. Registering prefabs - try loading each folder ins$$anonymous$$d of everything in resources

      using UnityEngine;
         using UnityEngine.Networking;
         using System.Collections;
         
         public class RegisterPrefabs
         {
             public static void RegisterAll()
             {
                 foreach (GameObject temp_ent in Resources.LoadAll<GameObject>("Prefabs/"))
                 {
                     if (temp_ent.GetComponent<NetworkIdentity>())
                     {
                         ClientScene.RegisterPrefab(temp_ent);
                     }
                 }
             }
         }
    
  2. $$anonymous$$ake sure you only call the registering method when isLocalPlayer is true on a player

  3. $$anonymous$$ake sure you're calling NetworkServer.Spawn() on Server with [Server] or [ServerCallback]

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

52 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

Related Questions

What does this error mean? 1 Answer

Networking concept and spawning questions 1 Answer

Cannot Spawn networkbehaviour gameobject 0 Answers

Command function called on server 0 Answers

UNET 5.4 - Spawn an object from client...and move it around from client....? 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