Question by
JackTheKreator · May 09, 2016 at 05:40 PM ·
multiplayerfpsweapon
Big problem with weapon eqipping in multiplayer fps
My goal is to equip a weapon with this function on the player object. I have lots of guns, so it takes a prefab as an argument.
public void EquipWeapon(GameObject Weapon){
GameObject wep = Instantiate (Weapon);
wep.transform.parent = Gimbal.transform;
NetworkServer.SpawnWithClientAuthority (wep, connectionToClient);
}
But when I use this (to equip the default gun i use
public override void OnStartLocalPlayer ()
{
EquipWeapon (Testweaponequip);
Debug.Log ("Player started");
}
but it only works on the server. The client's gun also shows up, but it isnt in the editor hierarchy, and it cant shoot. I also cant see it on the the host. Can anyone help me to instantiate weapons for players? BTW, the guns have networkidentities and so do the players.
Comment
Answer by NFMynster · Aug 26, 2016 at 08:15 AM
You need to setup all the spawnable prefabs in the networkmanager's list.
Your answer
![](https://koobas.hobune.stream/wayback/20220612080449im_/https://answers.unity.com/themes/thub/images/avi.jpg)