- Home /
 
 
               Question by 
               kadealicious · Jun 12, 2017 at 09:07 AM · 
                c#networkingnetworkmultiplayer-networkingnetwork instantiate  
              
 
              Player object on host can interact with objects, client players cannot.
I have looked all over but to no avail. Objects that are spawned in have a Network Identity and a Network Transform attached to them, and the host player can move them around. However, the client player can move objects around on his/her screen, but they don't move on the host's side. They just stay still. Would I need to use a [ClientRPC] or a [Command] function to send transform data over the Network? Would there be a different way to spawn objects over the Network? Here is my object spawning code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class SpawnObject : NetworkBehaviour
 {
     [SerializeField]
     private GameObject prefabtospawn = null;
     void Start()
     {
         CmdSpawnNetworkObject();
         Destroy(gameObject);
     }
     [Command]
     void CmdSpawnNetworkObject()
     {
         ClientScene.RegisterPrefab(prefabtospawn);
         GameObject obj = (GameObject)(Instantiate(prefabtospawn, transform.position, transform.rotation));
         NetworkServer.Spawn(obj);
     }
 }
 
              
               Comment
              
 
               
              Your answer