private void Start() { Transform itemParent = transform.FindChild("ItemInChestParent"); if (itemParent.childCount == 0) return; itemInChest = itemParent.GetChild(0).GetComponent<ItemGameObject>(); itemInChest.gameObject.SetActive(false); itemInChest.transform.position = transform.position; Destroy(itemInChest.GetComponent<Rigidbody>()); itemInChest.gameObject.layer = 0; itemInChest.GetComponent<Collider>().isTrigger = true; itemInChest.GetComponent<Collider>().enabled = false; }
private void PickUpItem(ItemGameObject item) { audioSource.PlayOneShotWithRandomPitch(AudioManager.Instance.PickUpObjectClip, 0.2f); ItemGameObject i = item.GetComponent<ItemGameObject>(); if (i.Type == ItemType.Potion) Player.Instance.Potions++; else Player.Instance.Inventory.AddItem(new ItemData(i.Name, i.Type, i.MeshName, i.Sprite, i.Points, i.WeaponLength, i.AttackAngle)); Destroy(item.gameObject); }