using System.Collections; using System.Collections.Generic; using UnityEngine; public class PowerDrop : MonoBehaviour { public float powerAmount = -100.0f; private float timeTillSelfPop; [SerializeField] private UnityEngine.UI.Text textField; private bool popped = false; void OnTriggerEnter(Collider other) { if (!popped) { if (other.tag == "Player") { other.GetComponent().PowerLevel += powerAmount; popped = true; Pop(); } } } // Use this for initialization void Start () { textField.text = "+" +powerAmount.ToString(); timeTillSelfPop = 10.4f; } // Update is called once per frame void Update () { timeTillSelfPop -= Time.deltaTime; if (timeTillSelfPop < 0) { Pop(); } } private void Pop() { GameObject.Destroy(gameObject); } }