Linking two gameobjects on client and server

Hi.

In my game i spawn objects manually. The prefab has network idendity and network transform components on it.

in my test scene. when i press the play this prefab being spawned on client and host independent from network.
Then i connect Client to the Host. Now the thing that i want to do is linking these gameobjects between host and client. How ?

Thanks

Test project is included at the attachment

2292460–154210–TestProj.zip (175 KB)

Ok i’ve achived this :slight_smile:

public class NetTest : NetworkManager {

    public GameObject ccaa;
    GameObject pop;
    public bool usclient;
   
    const short MyBeginMsg = 1002;
    void Start(){
       
        pop = (GameObject)Instantiate(ccaa, Vector3.zero, Quaternion.identity);
        if (Application.isEditor) {
           
        }

    }
    public void Init()
    {

    }
    public override void OnStartHost(){
        //base.OnStartHost();
       
    }
    //Called on the server when a new client connects.
    public override void OnServerConnect(NetworkConnection conn) {
        //base.OnServerConnect(conn);
        Debug.Log(conn.connectionId + " : isConnected");
    }
   

    //Called on the server when a client adds a new player.
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        Debug.Log(conn.connectionId + " : is requested spawn with " + playerControllerId + " playerControllerId" );
        NetworkServer.AddPlayerForConnection(conn, pop, playerControllerId);
        //NetworkServer.ReplacePlayerForConnection(conn,pop,playerControllerId);
    }
   
    //Called on the client when connected to a server.
    public override void OnClientConnect(NetworkConnection conn)
    {
        ClientScene.Ready(conn);
        //base.OnClientConnect(conn);
        if (!Application.isEditor) {
            //ClientScene.AddPlayer
           
            ClientScene.RegisterPrefab(pop,SpawnHandler,UnSpawnHandler);
            ClientScene.AddPlayer(conn,0);
            //base.OnClientConnect(conn);
            //ClientScene.SetLocalObject(pop.GetComponent<NetworkIdentity>().netId,pop);
            //NetworkServer.ReplacePlayerForConnection(conn,pop,3);
        }
    }
   
    public override void OnClientDisconnect(NetworkConnection conn)
    {
        //StopClient();
    }
        private  GameObject SpawnHandler(Vector3 position, NetworkHash128 assetID)
    {
        Debug.Log("Called Spawn Handler");
        return pop;
    }
    
    private  void UnSpawnHandler(GameObject gameObject)
    {
        Debug.Log("Called UnSpawn Handler");
    }

   
    public override void OnServerReady(NetworkConnection conn)
    {
        Debug.Log(conn.connectionId + " : is Ready");
    //NetworkServer.SetClientReady(conn);
    }
   
   
}