• 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
1
Question by Zero123 · Mar 28, 2016 at 02:39 PM · unity 5networkinglist

sync list of gameobjects accross network

Hello I am trying to synchronize a list of game objects across the network. i want each player to have the same copy of the list. once any player adds or removes a game object it should be updated across the network. The initial list should be created by the server and initialized to all connected clients. I know i am supposed to use ClientRPC, but i cant seem to figure out how to use them. i have a bunch of code but its too broken to post here. If someone can point me in the right direction it would be good.

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
0

Answer by Krunal_vasundhara · Sep 28, 2017 at 07:01 AM

I think SyncList* classes are one way to synchronize the List in unity networking.

For more details https://docs.unity3d.com/ScriptReference/Networking.SyncList_1.html

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

Answer by khoucem · Oct 08, 2017 at 12:31 PM

Same problem , I know that i shoud use synclists. Please can any point me how to use theme beacause i 'm getting errors . here is the code i used :

 public SyncList<GameObject> Cards;
 
 public override void OnStartServer(){
         NetworkManager netM = NetworkManager.singleton;
         cardsList = netM.spawnPrefabs;
         foreach (GameObject gO in cardsList) {
             Cards.Add (gO);
         }
         distributeCards ();
 
 
     }

this code will try to add gameobjects from the registered spawnable prefabs list on the network Manager to synchronized list , but i get this error while runing in the console :

 Exception in OnStartServer:Object reference not set to an instance of an object   at Player.OnStartServer () [0x00035] in C:\Users\Houcem\Documents\Ballet\Assets\Scripts\Player.cs:32 
   at UnityEngine.Networking.NetworkIdentity.OnStartServer (Boolean allowNonZeroNetId) [0x00140] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:338 
 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
 

Please can one help ?

@Krunal_vasundhara

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.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to disbale a network start position on runtime 0 Answers

How to spawn projectiles on the server from a client. 0 Answers

Object reference not set without object? Calling ListMatches and getting this error 2 Answers

Using syncVar in networkManager 1 Answer

Command function called on server 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