- Home /
Transform.Parent Not Working
if(health == 0){
Destroy(Transform.parent);
Destroy(gameObject);
}
Only the gameObject itself is being destroyed not the parent. Is the gameObject itself being destroyed first?
Answer by Jessy · Jun 10, 2012 at 04:25 AM
Don't use a capital T. That code won't even compile.
I'm assuming your actual code doesn't look like that. Read your Console before you post here.
Can't destroy Transform component. If you want to destroy the game object please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
Yeah, but when I looked at other answers to destroying the parent they said that. I didn't use capital T in my actual code. How am I supposed to destroy the object ins$$anonymous$$d? I've tried gameObject.parent and several, several other things. Why did you thumb me down? You didn't even give me an answer.
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Checking to see if there are no more of a certain object in the scene? 1 Answer
change pivot of parent game object 1 Answer
Destroying objects 1 Answer
Building asset bundles and wanting to move game objects from one parent to a newly created parent 1 Answer