private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(furnitureTag)) { furnitures.Add(other.gameObject); } if (other.gameObject.CompareTag(weaponTag)) { ItemGun item = other.gameObject.GetComponent <ItemGun>(); SelectWeapon(item.weaponIndex); item.Kill(); } }
void Start () { ItemGun[] array = (ItemGun[]) GameObject.FindWithTag("Player").GetComponentsInChildren<ItemGun>(); int i = 0; weapon = array[0]; while(i < array.Length) { if(array[i].id < weapon.id) { weapon = array[i]; } i++; } canvTexts = this.GetComponentsInChildren<Text>(); bulletGui = (Text) canvTexts[0]; ammGui = (Text) canvTexts[1]; bulletGui.text = " "; ammGui.text = " "; }