using UnityEngine; using System.Collections; public class EnemyBulletScript : MonoBehaviour { bool fired; void Start () { fired = false; } void Update () { } void OnTriggerEnter2D(Collider2D col) { if (!fired) { var player = col.gameObject.GetComponentInParent(); if (player != null) { fired = true; player.TakeDamage(20f); Destroy(gameObject); } } } }