Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by temporaryman1 · Jan 24, 2013 at 04:52 PM · gameobjectdestroychildren

Wont destroy child-gameObjects

When I destroy my enemy i have called bomberman It only destroys the collider by the looks of it and I just cant collide with the object anymore.

alt text

So there is a script attached to enemies->bomberman which destroys the gameObject. I assumed it would destroy enemies-bomberman->bomberman and enemies->bomberman->bombermanparticles but it doesnt.

Can anyone help?

here is the script attached to bomberman.

 function OnCollisionEnter (hit : Collision){
 
 Debug.Log("Colliding with an object: " + hit.collider.gameObject.name);
 if(hit.collider.gameObject.name == "ball" || hit.collider.gameObject.name == "dbz_ball(Clone)"){
 damage += 1;
 }
 health = maxhealth - damage;
 
 redColor = damage/20;
 Debug.Log("health is: " + health);
 
 //Debug.Log("red color is: " + redColor);
 //enemyRenderer.renderer.material.color.r = redColor;
 //enemyRenderer.renderer.material.color.b = 0;
 
 //enemyRenderer.renderer.material.color.g = 0;
 
 var color : Color = new Color(redColor, 0.0f, 0.0f);
 enemyRenderer.renderer.material.color = color;
 
 audio.Play();
 
 if(health < 1){
 health = 0;
 var clone = Instantiate(explosion, transform.position, transform.rotation);
 Debug.Log("gameObject should be destroyed");
 
 Destroy(gameObject.transform);
 Destroy(gameObject.gameObject);
 Destroy(gameObject);
 
 Destroy(clone.gameObject, 2);
 }
 
 }
screen shot 2013-01-24 at 16.39.01.png (6.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Tourist · Jan 24, 2013 at 04:55 PM

Destroy(gameObject.gameObject); Destroy(gameObject);

are the same instruction.

I think u mean gameObject.transform.parent.gameObject

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image temporaryman1 · Jan 24, 2013 at 05:23 PM 0
Share

hi this didnt work.

avatar image temporaryman1 · Jan 24, 2013 at 05:47 PM 0
Share

ok now I somehow got it working I have a new problem. It ONLY deletes the child objects but not itself even when I call Destroy(gameObject);

avatar image Tourist · Jan 24, 2013 at 06:06 PM 0
Share

name each object with an unique name, and use debug log to see which gameobject you are deleting

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

destroying children also destroys parent itself 4 Answers

destroying children of a gameobject 1 Answer

Destroy object when transform.position.x > 10. 1 Answer

Destroy(gameObject) does not work 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges