Hi, i have a script that spawns an object when player clicks “M”.
When host clicks M ,the object spawns on every client and server.
When client clicks M, the object doesn’t spawn at all.
I’ve been doing research but i couldn’t find any correct answer. Everybody just say: Use networkserver.spawn();. It doesn’t work in my case on client; it works just on host.
My question is: How can i make client spawn an object over network?
Code:
[Command]
public void CmdPlaceTrap(GameObject go)
{
if (trapsCount != 0)
{
GameObject go_ = (GameObject)Instantiate(go, cursor.transform.position, this.transform.rotation);
NetworkServer.SpawnWithClientAuthority(go_,this.gameObject);
trapsCount--;
RpcPlaySfx(go_);
}
}
[ClientRpc]
void RpcPlaySfx(GameObject goRPC)
{
AudioSource.PlayClipAtPoint(trapClipPlace, goRPC.transform.position, 3f);
}
~ Regards
EDIT: By the way; NetworkServer.Spawn(); Doesn’t work too.