[uNET] Network objects spawned not spawn in new clients
Hi guys, how you guys can saw in the title, i'm facing a problem and i can't figure out how to resolve that... I googled and searched in the internet for 3 days, and still not getting how to work that... Well, basicaly I have a script that spawn a weapon to players, everything works fine on client-host, but when i connect with other clients, the last client connected, not spawn the weapons instantiated before like weapon spawned on the client-host... Let me explain better: I start a host, the weapon spawn localy and on the server. I connect a client, the client spawn the weapon localy and on the server too. On host-client, the weapon of the client spawns fine but in the client, the host-client's weapon already spawned, not spawn in the client... I Connect a third client to see better and when i connect the third client, the second client spawn the weapon of the third client, but the host-client's weapon still not... And like a said before, the host-client and the second client, not spawn at all the weapons on the third... In the host-client, it spawns the weapons of all clients that connect... Long story short, all clients that connect, spawns the weapons in the host-client, and in the clients already connected, but if some client or the host, spawn the weapon before a client connect, that client not spawn the other clients weapons...
Here the code that spawn the weapons:
void Start()
{
if (isLocalPlayer)
Cmd_InstantiateWeapon ();
}
[Command]
void Cmd_InstantiateWeapon()
{
GameObject _gm = Instantiate(Resources.Load("Weapons/TestPistol")) as GameObject;
_gm.GetComponent<Weapon> ().parentNetId = GetComponent<NetworkIdentity> ().netId;
_gm.transform.SetParent (_hand.transform, false);
NetworkServer.SpawnWithClientAuthority (_gm, this.gameObject);
Debug.LogWarning ("Spawned weapon in a server");
}
If someone could help-me, i would aprecciate... I'm 3 days trying to resolve that and i can't figure out how to do...
Answer by recagonlei · Nov 27, 2016 at 07:21 PM
I was spawning the objects deactived, because of that it was not spawning in new clients...