- Home /
 
               Question by 
               Saskaham_Gaming · Oct 19, 2020 at 09:36 AM · 
                prefabdestroydestroy object  
              
 
              Destroying Object without removing attached prefab, How can I destroy an object without destroying the original prefab attached?
Hello, I am trying to destroy an object instantiated from a prefab, when I use the destroy() function it deletes that object but then it also deletes the prefab that is attached to a slot in the inspector and shows it as missing, is there anyway I could delete that object without destroying the attached prefab?
               Comment
              
 
               
              Answer by NoahDaNerd · Oct 19, 2020 at 12:19 PM
You should get a reference to the prefab in your script, then unparent it before destroying it.
 public GameObject attachedPrefab;
 attachedPrefab.transform.parent = null;
 Destroy(objectToDestroy);
Your answer
 
 
             Follow this Question
Related Questions
Destroying an instantiated prefab particle effect 4 Answers
How to spawn a 'boss' after all enemies defeated and then kill that 'boss'? 1 Answer
Destroy Prefab clone 2 Answers
Destroying Objects. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                