Question by
blackroomboy · Apr 05, 2018 at 12:41 PM ·
unity 2ddestroycloneprefab-instance
Not being able to destroy clone of prefab.
I have a Blood splash prefab and it shows up when I kill an enemy. I want it to be destroyed and removed from the game screen after a while. Despite using the Destroy() method, it doesn't get destroyed and remains on the screen. Here's the code:
if (currentHealth <= 0)
{
currentHealth = 0;
isDead = true;
BloodSplashPrefab.position = transform.position;
Transform clone = (Transform) Instantiate(BloodSplashPrefab);
Instantiate(clone);
Destroy(clone.gameObject, 3);
if (clone.gameObject != null)
{
Debug.Log("Not Destroyed");
}
}
I get the message that it has not been destroyed. Please help.
Comment
Your answer
Follow this Question
Related Questions
[SOLVED] How to destroy a cloned object if it object colliding with another cloned object ? 1 Answer
Cannot destroy the SphereCollider on Instantiated Objects 1 Answer
Delete gameobject clone after a new one spawnes. 2 Answers
Destroy not working and weird behaviors ( multiple clones ) 0 Answers
Destroy the first instantiated clone after 4 have been instantiated 1 Answer