Game Object no initiating

SCARFACE
✭
I am doing a tutorial in which we when we spawn player we instantiate some weapons on it but the problem is the weapons are not instantiating in my case.
public void AddWeapon(WeaponID id) { if (id == WeaponID.None) return; GameObject prefab = null; foreach (GameObject w in _weaponPrefabs) { if (w.GetComponent<Weapons>().WeaponStat.ID == id) { prefab = w; break; } } prefab = Instantiate(prefab, _weaponsTransform.position, Quaternion.LookRotation(_weaponsTransform.forward), _weaponsTransform); if (id < WeaponID.SecondaryEnd) { _secondary = id; _weapons[1] = prefab.GetComponent<Weapons>(); prefab.GetComponent<Weapons>().Init(this, 1); } else { _primairy = id; _weapons[2] = prefab.GetComponent<Weapons>(); prefab.GetComponent<Weapons>().Init(this, 2); } }
here is the code i use an array to store weapon prefabs and then it should instantiate and add those weapons to Weapon array but that is not happening and i don't know why.
0
Answers
-
Sorry, we can't really help with "some tutorial". Please ask the author of said tutorial. Maybe something is missing in the article / video?!
0