Question by
starazure · May 28, 2017 at 02:59 PM ·
transformdestroydestroy object
Unity - Opposite of instantiate - destroyed but not removed
Hello, I an trying to destroy prefab1 below ( destroying its game object) in update but the prefabs do not get removed in my game. DESTROYING HOLE 1 GEMS debug below appears in console and gameobject is destroyed but the gems (prefab sprites) do not get removed from my game even when gemCount_Hole1 is less than 1. Please help !
if (gemCount_Hole1 < 1)
{
Debug.Log("DESTROYING HOLE 1 GEMS");
if (prefab1 != null) Destroy(prefab1.gameObject);
}
else
{
for (int i = 0; i < gemCount_Hole1; i++)
{
Instantiate(prefab1, new Vector3((i + xPos_Hole1) * 2.0F, -14, 0), Quaternion.identity);
}
}
Comment
Your answer
Follow this Question
Related Questions
Create new transform when other transfrm is destroyes 1 Answer
Player falls through destroy collider 1 Answer
[SOLVED] How to destroy a cloned object if it object colliding with another cloned object ? 1 Answer
Simple call animation then destroy? 0 Answers
Objects getting destroyed in unity test, but only sometimes in the phone app 0 Answers