Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / Colectible Inventory / Memory.cs
@Rackday Rackday on 21 Aug 2024 504 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Memory : MonoBehaviour
  5. {
  6. [SerializeField] private Item myMemory;
  7. [SerializeField] private Inventory inv;
  8. private void Start()
  9. {
  10. foreach(Item i in inv.inventory)
  11. {
  12. if (i.name == myMemory.name) Destroy(gameObject);
  13. }
  14. }
  15. private void OnCollisionEnter(Collision collision)
  16. {
  17. inv.inventory.Add(myMemory);
  18. Destroy(gameObject);
  19. }
  20. }