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
1
Question by CommandoJones · Jun 23, 2015 at 11:12 PM · unity 5networkingunity5

UNET Player Object Creation Error: Failed to spawn server object

I am attempting to create a player object for a connecting client. I have set the PlayerPrefab variable to be an empty object with a NetworkIdentity attached to it. The issue is that once the client connects, the player object is created on the server but the client gets this error:

 Failed to spawn server object
 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate(). 

I am not sure if there is something that I have set up incorrectly on the server or client in order to get this error. The client does connect to the server and switch scenes successfully just before this happens.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by CommandoJones · Jun 25, 2015 at 12:45 PM

So for anyone else dealing with this problem, I found my solution. I have my client and server code in two separate projects which was an issue because the player prefabs for the client and server must share the same meta file in order to work. This could also be the case for any networked object someone might want to create through NetworkServer.Spawn() but I have not tested it personally. Good luck to anyone dealing with a similar issue.

Comment
Add comment · Show 18 · 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 iyakov · Jun 25, 2015 at 06:15 PM 0
Share

CommandoJones, could you please share the demo project? I have issues with spawning..

avatar image CommandoJones · Jun 25, 2015 at 06:38 PM 0
Share

Hey iyakov, unfortunately I don't have a small demo project to share. I found this issue while working on a rather large code base. However I can say that my particular issue with spawning a player object happened because I have two separate projects. One for the server and one for the client.

So when I assigned my player objects, the prefabs I was using did not share the same meta data which caused issues. If you are having a similar issue but you have one project for both your server and client code then I am not entirely sure what may be the cause.

I hope this helps!

avatar image iyakov · Jun 25, 2015 at 09:10 PM 0
Share

$$anonymous$$ay be you may note my mistake:

Projects running on 2 UNITYs:

One project for a client;

One project for a server;

Each project has a GameObject with a Network$$anonymous$$anager;

Prefab:

The same meta, the same settings (Local Player Authority);

The prefab has NetworkIdentity And NetworkTransform;

client code:

 public class DemoBehaviour : $$anonymous$$onoBehaviour
 {
     public Network$$anonymous$$anager $$anonymous$$anager; // Link to the same GO's component
     public GameObject DemoPrefab; // Link to the spawn prefab
 
     // Use this for initialization
     void Start ()
     {
         $$anonymous$$anager.StartClient();
         ClientScene.RegisterPrefab(DemoPrefab);
     }
 
     void OnGUI()
     {
         // this spawns only on client
         if (GUILayout.Button("Create"))
         {
             GameObject obj = GameObject.Instantiate(DemoPrefab);
             NetworkServer.Spawn(obj);
         }
     }
 }

server code:

 public class DemoBehaviour : $$anonymous$$onoBehaviour
 {
     public Network$$anonymous$$anager $$anonymous$$anager;
     public GameObject DemoPrefab;
 
     // Use this for initialization
     void Start()
     {
         $$anonymous$$anager.StartHost();
         ClientScene.RegisterPrefab(DemoPrefab);
     }
 
     void OnGUI()
     {
         // this spawns on both client & server. Only server can control
         if (GUILayout.Button("Create"))
         {
             GameObject obj = GameObject.Instantiate(DemoPrefab);
             NetworkServer.Spawn(obj);
         }
     }
 }
avatar image CommandoJones · Jun 25, 2015 at 09:39 PM 0
Share

Oh I see, are you getting the, Failed to spawn server object, error as well? I have not messed with NetworkServer.Spawn myself yet. I have only used the automatic PlayerObject spawning. However I am fairly certain that you don't need the OnGUI() code on the client since you can only spawn networked objects through the server. Going based off of the documentation below in the, Object Creation Flow, section.

Other than that as far as I can tell you haven't actually connected the server to the client. Unless you just didn't include that in your code snippet, in which case I am not entirely sure what is the issue. What you have shown me looks pretty straight forward.

http://docs.unity3d.com/$$anonymous$$anual/UNetSpawning.html

avatar image iyakov · Jun 25, 2015 at 09:45 PM 0
Share

Oh, it's a pity. Btw, I don't use a custom connect, so a single call to Network$$anonymous$$anager.StartClient calls connect, ready and addplayer methods.

Please note:

this spawns on both client & server. Only server can control it

When I create a prefab at the server, it creates at the client side! However, only server can move the object so the client see its movement. But not vice versa. And I'm going crazy about this.

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

ClientRpc Function not being carried out on all clients in Unity3d c# 0 Answers

Unet CCU Exceeded by appID: Not going down 0 Answers

[Unity3d 5.1] Multiplayer - Multiple match - dedicated server 1 Answer

Unet NetworkServer.Spawn() not working 5 Answers

UNET Client Ready Flag Inconsistancy 2 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