using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Points : MonoBehaviour { [HideInInspector] public Counter counter; [Header("Число очков")] [SerializeField] private int points=0; [Header("Число здоровья (от 0 до 100)")] [SerializeField] private int health=0; [HideInInspector] public hp HP; private void Start() { counter = FindObjectOfType(); HP = GameObject.FindGameObjectWithTag("Player").GetComponent(); } private void OnTriggerStay2D(Collider2D other) { HP.SetHealth(health); counter.total += points; Destroy(this.gameObject); } }