using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnergyItem : MonoBehaviour, ICollectable { [SerializeField] private float _energy = 1; private EnergyController _energyController; private void Awake() { _energyController = FindObjectOfType(); } public void Collect() { _energyController.Energy += _energy; Destroy(gameObject); } }