using System.Collections; using System.Collections.Generic; using UnityEngine; public class Collectible : MonoBehaviour { [SerializeField] private int amount; [SerializeField] private float rotSpeed; [SerializeField] private float timeToAppear; void Update() { transform.Rotate(0, rotSpeed, 0, Space.World); } private void OnTriggerEnter(Collider other) { if(other.gameObject.tag.Equals("Player")){ other.gameObject.GetComponent().AddCharge(amount); Vanish(); } } private void Vanish(){ gameObject.SetActive(false); Invoke("Appear", timeToAppear); } private void Appear(){ gameObject.SetActive(true); } }