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 /
This question was closed Feb 16, 2017 at 06:55 PM by Xergz for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by Xergz · Feb 17, 2017 at 10:04 PM · networkspawncommandbasic

NetworkServer.Spawn not working with no error message

Hey guys! I know this might be a common problem, but I couldn't find anything I hadn't already tried anywhere.

Basically, my prefabs get instantiated properly on the host but NetworkServer.Spawn() doesn't seem to do anything since they never appear on the clients. I've tried registering the prefabs manually in the editor and in code on the server (I wasn't sure if it had to be called on clients too), but nothing worked.

I only get a warning if I add a NetworkTransform to the object and make it move: Did not find target for sync message for ID

I am never destroying the objects and I use reliable sequenced for my channel 0 so I don't see any reason why the target would not be found.

Here is my NetworkManager, my player prefab and the prefab for the object I am spawning:Prefabs

Here is the code for the player:

 public class SimplePlayer : NetworkBehaviour {
 
     [SerializeField]
     private NetworkIdentity _Identity;
 
     [SerializeField]
     private GameObject _Spawnable;
 
 
     private void Start () {
         if(_Identity.isLocalPlayer) {
             CmdSpawn();
         }
     }
 
     [Command]
     private void CmdSpawn() {
         var instance = Instantiate(_Spawnable);
         NetworkServer.Spawn(instance);
     }
 }

And here is the code for the spawnable (it's only to have it moving):

 public class SimpleMove : NetworkBehaviour {
 
     private int multiplier = 1;
 
     [ServerCallback]
     private void Update () {
         transform.position += multiplier * Vector3.up * Time.deltaTime * 3F;
 
         if(transform.position.y > 3F)
             multiplier = -1;
         else if(transform.position.y < -3F)
             multiplier = 1;
     }
 }

Is there something I am doing wrong? What am I missing? I read the doc about object spawning on Unity's website and I can't figure out what's wrong.

Thanks for your help!

screenshot-2017-02-16-123814.png (176.9 kB)
Comment
Add comment · Show 1
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 Xergz · Feb 16, 2017 at 06:55 PM 0
Share

I just found the problem. It seems I misunderstood the Server Only checkbox from the NetworkIdentity component. It actually means that it exists only on the server while I thought it meant it was controlled by the server.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

UnityScript not recognizing NetworkServer "Unknown Identifier" 0 Answers

Networking Basics Big Problem 1 Answer

UNET : SyncVar value not updating, hooks firing 1 Answer

Desync between host and client. 0 Answers

How to acess script from Command Method 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