- Home /
Trouble "Spawning" Objects on client (UNET networking)
i have a problem about spawning objects on clients, basically im trying to have a player equip a weapon when a number on the keyboard is pressed, this all works perfictly except for when a client connects, the other client can not see the weapon, i know the client can NOT preform networkserver.Spawn and im pritty sure thats why when the server equips it the client can see but when the client equips it the server cannot. i have been searching for an awnser to this problem and have come up with nothing, as a list of things i have seen and tried - the weapon prefab is added to the network manager i have tried adding a [Command]
infront and a[ClientRPC], the RPC just sends everytihing crazy while the command sorta works but just disables the whole scrip because clients dont have authority to preform command. i have also tried putting a ClientScene.RegisterPrefab (prefab);
and a NetworkServer.SpawnWithClientAuthority(prefab, base.connectionToClient);
instead of Networkserver.Spawn(prefab);
no effect
my script
GameObject equippedobj = Instantiate (prefab, position, Quaternion.identity, child);
ClientScene.RegisterPrefab (prefab);
NetworkServer.SpawnWithClientAuthority(prefab, base.connectionToClient);
the child at the end of the instansiate is there because the prefab is a child of the player (possibly problem?) ive seen stuff about how when things are spawned over the network they dont spawn as a child even if the instansiate says to please help i really cant seem to find an awnser to this problem