using System.Collections; using System.Collections.Generic; using UnityEngine; public class пуля : MonoBehaviour { public float damage; public float speed; public hp hp; private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag=="Player" || collision.gameObject.tag=="Enemy") { hp = collision.GetComponent(); hp.SetDamage(damage); Destroy(gameObject); } } void Start() { StartCoroutine(Delay()); } IEnumerator Delay() { yield return new WaitForSeconds(1f); Destroy(gameObject); } void Update() { transform.Translate(speed,0,0); } }