Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 olivers89 · Jun 23, 2015 at 03:00 PM · javascriptcollisioncloneprefab-instancedestroy-clones

Destroy Cloned Object on Collision

hello uniters,

i would like to destroy an object that is cloned on collision the specific object is cloned beforehand, and i would like to destroy the one specific that collides with the player. now i have the problem that sometimes another cloned object gets destroyed instead. not the one actually triggering the onCollision Destroy.

here you can check out what i got so far

this is my function:

 function OnCollisionEnter(collision:Collision)
  {
  
 
      if( collision.gameObject.tag == "Player" )
      {
          Instantiate(GameObject.FindWithTag("Exp"), transform.position, Quaternion.identity);
         Destroy(collision.gameObject.Find("ShootBomb(Clone)"));
      }
  }
  

additional ramble:

Obviously far from finished, the art,music and fonts are either from public tutorials or the asset store / my iTunes library and not credited yet, as i plan to replace them, once the mechanics work as they should. and really the only two things in my way are the wrong destructions of the bombs, and an animated player character. (the game is initially made for android (specifically the htc one mini) so you need to move the player to trigger a bomb, on the phone the mechanics work a bit better, as the gyro acceleration makes it extremely difficult to keep the player in place.

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
1

Answer by Ibzy · Jun 23, 2015 at 03:12 PM

Try this:

 GameObject bombClone = Instantiate(GameObject.FindWithTag("Exp"), transform.position, Quaternion.identity) as GameObject;
 Destroy(bombClone);

This gives you a reference to the object you instantiated and then allows you to destroy it specifically. I assume there is some form of delay between these 2 actions though?

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

clone functions 2 Answers

Object Collision PLEASE HELP!!! 1 Answer

My Javascript collision isn't being detected, please help. 0 Answers

Destroy Clones One At A Time Javascript 0 Answers

Detect collision and destroy one object 0 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