private bool AddGunModifier(GunModifier m) { if (current_modifiers < modifiers.Length) { modifiers[current_modifiers] = m; Component mod = gameObject.AddComponent(m.GetType().ToString()); //EditorUtility.CopySerialized(m, mod); ((GunModifier)(mod)).Equip(this); current_modifiers++; return(true); } return(false); }
public void PickUpModifier(float radius, int slotIndex) { Collider[] colliders = Physics.OverlapSphere(player.transform.position, radius); for (int i = 0; i < colliders.Length; i++) { print("D: " + i); if (colliders[i].tag == "GunModifier") { print("modifier!"); GunModifier m = (GunModifier)(colliders[i].transform.parent.gameObject.GetComponent("GunModifier")); AddGunModifier(m); } } }
private bool AddGunModifier(GunModifier m) { if (current_modifiers < modifiers.Length) { modifiers[current_modifiers] = m; Component mod = gameObject.AddComponent(m.GetType().ToString()); //EditorUtility.CopySerialized(m, mod); ((GunModifier)(mod)).Equip(this); current_modifiers++; return true; } return false; }