so im new to game making and stuff and i am trying to make this simple space shooter game. when i fire bullet hit the target destroys it and explosion animation is played but the last frame is stuck on the screen rather then completely disappearing. for animation im using a prefab here is my script for enemy:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour {
public int health = 100;
public GameObject deathEffect;
public void takeDamage(int damage)
{
health -= damage;
if (health <= 0)
{
die();
}
}
void die()
{
Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}