Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static HealthItem[] itemsInInventory;
- void Start()
- {
- itemsInInventory = new HealthItem[5];
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- if (other.gameObject.tag == "Collectable")
- {
- if (itemsInInventory.Length >= 9)
- {
- for (int i = 0; i < itemsInInventory.Length; i++)
- {
- if (itemsInInventory[i] == null)
- {
- HealthItem tempItem = other.GetComponent<HealthItem> ();
- itemsInInventory[i] = Instantiate(tempItem) as HealthItem;
- Destroy(other.gameObject);
- return;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment