1234567891011121314151617181920212223242526272829303132333435 |
- 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>();
- 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);
- }
- }
|