• 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 ctheroux · Apr 25, 2013 at 02:38 AM · colliderdestroygameobject

Two objects BOTH with Destroy(other.gameObject) aren't destroying each other??

possibly a newby question here, but.. i've got two bullet objects that, when they hit eachother, won't destroy each other... both have rigidbodies and colliders, one with a tag check,one without any tag checking.. (come at bottom) they both destroy everything else they are supposed to destroy, but when they hit eachother they just bounce and float off.. at first i thought it was from detectcollision, but then they wouldn't bounce, just pass through, so i don't have a clue what's up..

code 1, on "bullet" object tagged "Player"

 function OnTriggerEnter (other : Collider) 
 {
     Destroy(other.gameObject);
     Destroy(this.gameObject);

}

code 2, on "enemybullet" object tagged "Enemy" (yeah i know, real original huh?)

 function update()
 {
  rigidbody.detectCollisions = false;
  if (transform.position.z <= -13)
  {
  rigidbody.detectCollisions = true;
  }
 if (transform.position.z <= -20)
 {Destroy(this.gameObject);}
 }
 
 
 function OnTriggerEnter (other : Collider) 
 {
 
   
    if(other.gameObject.tag=="Player")
    {
     Destroy(other.gameObject);
     Destroy(this.gameObject);
      Debug.Log("EXTERMINATE!");
      AddSingleCubeFab.prevFab =false;
     }
   
 }
 
     i took classes in c++ but my scripting class is using javascript, so i'm learning as i go here, any help would be GREAT!
     
Comment
Add comment · Show 3
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 moha · Apr 25, 2013 at 07:21 AM 0
Share

are your bullets collider two primitives collider or two meshes collider. because collision between two meshes collider which are no primitives (cube, etc...) are not doing well.

avatar image ctheroux · Apr 25, 2013 at 08:28 AM 0
Share

two primitives.. 1. sphere prefab and 2. cylinder prefab. I'm still taking an introductory course, so they didn't extensively cover using meshes in this course. the only objects i use (rigidbody objects) are always primitives.

avatar image ctheroux · Apr 25, 2013 at 08:33 AM 0
Share

asafsitner: thanks you! previous reply doesn't seem to have gone through, so i'm saying again, thank you! didn't think of OnCollisionEnter ... i think i read about it, but i don't remember it being covered in class, so i was unfamiliar with it. after looking it up in the reference pages, it looks like it should work perfectly! i'm too tired to mess with it tonight, but tomorrow i'll try it out and once i've confirmed it works i'll switch this thread to "answered"

1 Reply

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

Answer by asafsitner · Apr 25, 2013 at 05:17 AM

Are they triggers at all? You say 'bounce off' which sounds to me like they have regular colliders, while you're trying to destroy them with an `OnTriggerEnter`.

Try to change that into `OnCollisionEnter`

Comment
Add comment · Show 1 · 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 asafsitner · Apr 25, 2013 at 11:34 AM 0
Share

Just converted this to an answer to keep from showing under 'unanswered' category

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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 avatar image avatar image avatar image

Related Questions

Internal collisions 1 Answer

Open a door by standing on a button 0 Answers

character controller only triggers colliders on its sides 1 Answer

Collider Activate Trigger Animation 0 Answers

OnTriggerEnter not being called with multiple colliders 1 Answer


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