public void OnOutOfBounds() { offscreen = false; // reseting offscreen value GameObjetcUtil.Destroy(gameObject); if (DestroyCallback != null) { // meaning a method has been set to this property // we attempt to calll the method thast connected to it DestroyCallback(); } }
void OnTriggerEnter2D(Collider2D hitInfo) { // Debug.Log(hitInfo.name); DestroyOffscreen enemy = hitInfo.GetComponent <DestroyOffscreen>(); if (enemy != null) { enemy.TakeDamage(damage); } // Instantiate(impactEffect, transform.position, transform.rotation); GameObjetcUtil.Destroy(gameObject); }