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 /
avatar image
0
Question by asperatology · Sep 05, 2015 at 04:16 PM · unity 5networkingprefabsgameobjectsclient-server

Client's list of game object prefabs not shown in the Server. How do I solve this?

I am using Unity 5.1.3f1, and the new UNET Networking API. I am making a simple RTS game in Unity.

I used a game object prefab to spawn in via Network Manager's Spawn Info properties in the Inspector. This game object prefab then spawns in a list of game object prefabs, which are managers that manage player actions, for my game.

The problem is that when the client connects to the server, the server does not see the client's list of game object prefabs.

alt text

The left side is the client, the right side is the server. I am pretty sure I registered all of the list of game object prefabs in the Network Manager. So, I can only isolate the problem down to "client's game objects are not shown in the server."

This is the Prefab Initialization code:

 using UnityEngine;
 using UnityEngine.Networking;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using Common;
 
 public class PrefabInitialization : NetworkBehaviour {
     public static PrefabInitialization Instance;
 
     public List<GameObject> gameObjectList;
     public CommonUnitManager unitManager;
     public CommonInputManager inputManager;
     public CommonAttackManager attackManager;
     public CommonMergeManager mergeManager;
     public CommonSplitManager splitManager;
 
     public void Awake() {
         PrefabInitialization.Instance = this;
     }
 
     private void SpawnObject(int i) {
         GameObject obj = GameObject.Instantiate(this.gameObjectList[i], Vector3.zero, Quaternion.identity) as GameObject;
         //GameObject obj = this.gameObjectList[i];
         obj.name = obj.name.Substring(0, obj.name.Length - "(Clone)".Length);
         if (obj.tag.Equals("Input_Manager")) {
             this.inputManager = obj.GetComponent<CommonInputManager>();
             this.inputManager.SetUnitManager(this.unitManager);
             this.inputManager.SetMergeManager(this.mergeManager);
             this.inputManager.SetAttackManager(this.attackManager);
             this.inputManager.SetSplitManager(this.splitManager);
         }
         else if (obj.tag.Equals("Merge_Manager")) {
             this.mergeManager = obj.GetComponent<CommonMergeManager>();
             this.mergeManager.unitManager = this.unitManager;
         }
         else if (obj.tag.Equals("Split_Manager")) {
             this.splitManager = obj.GetComponent<CommonSplitManager>();
         }
         else if (obj.tag.Equals("Attack_Manager")) {
             this.attackManager = obj.GetComponent<CommonAttackManager>();
         }
         else if (obj.tag.Equals("Unit_Manager")) {
             this.unitManager = obj.GetComponent<CommonUnitManager>();
         }
         else if (obj.tag.Equals("RPCLess_Unit")) {
             CommonUnit commonUnit = obj.GetComponent<CommonUnit>();
             commonUnit.transform.position = this.transform.position;
             commonUnit.unitManager = this.unitManager;
             if (!this.unitManager.getAllObjects().Contains(obj)) {
                 this.unitManager.getAllObjects().Add(obj);
             }
         }
         NetworkServer.Spawn(obj);
     }
 
     //public override void OnStartServer() {
     //    if (this.isServer) {
     //        this.SpawningInitialization();
     //    }
     //}
 
     public void SpawningInitialization() {
         for (int i = 0; i < this.gameObjectList.Count; i++) {
             this.gameObjectList[i].SetActive(true);
             SpawnObject(i);
         }
     }
 
     public override void OnStartLocalPlayer() {
         if (this.isClient) {
             this.SpawningInitialization();
         }
     }
 }

What am I missing? Thanks in advance.

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

2 People are following this question.

avatar image avatar image

Related Questions

UNET 5.2: How do you use NetworkServer.SpawnWithClientAuthority()? 1 Answer

login to the server in unity c# 0 Answers

[UNET] Only spawn certain server objects on local client? 0 Answers

Changing variable value Network 1 Answer

Commands and ClientRPC are not running when called 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