• 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 /
This question was closed Dec 16, 2017 at 02:45 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
10
Question by Benjaben · Feb 03, 2011 at 02:32 AM · collisionignore

Ignore Collision

I have a weapon that shoots a spread of rockets. I want the rockets to collide with walls and enemies, but not with each other. Right now they are all rigidbodies with box colliders on them. I have them set to destroy on collision with tags "Enemy" and "Wall". But they still collide with each other and bounce all over the place. Is there a way to have them ignore collision with each other?

I tried using

if(hit.collider.GameObject.CompareTag("Bullet"))
     Physics.IgnoreCollision(collider, hit.collider)

But that nothing changed at all. Any ideas?

Comment
Comments Locked · Show 1
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 Qwerty · Feb 03, 2011 at 02:46 AM 0
Share

Do they need to bounce off walls? or are they going to explode the second they hit either a wall or enemy?

3 Replies

  • Sort: 
avatar image
29
Best Answer

Answer by Mann1ng · Jun 08, 2011 at 03:34 PM

It is actually quite simple to do :

  1. Create a new layer called "Rockets"

  2. Set the Layer of the rocket prefab to "Rockets".

  3. Go to Edit > Project Settings > Physics

  4. Ensure that the checkbox in the Layer Collision Matrix is unchecked for Rocket-Rocket collision.

  5. That will disable all collision between rockets and othe rockets.

  6. Party on.

Comment
Comments Locked · Show 5 · 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 Alan47 · Aug 07, 2014 at 01:10 PM 0
Share

That is pure gold, thank you, I wasn't aware of this matrix before!

avatar image Milky655 · Aug 28, 2015 at 11:16 AM 0
Share

Oh $$anonymous$$y Jesus! Thank you $$anonymous$$ann1ng for this. I have slaved over this issue for about 3hrs now and you solved it in 2.8seconds. Thank you so much!

avatar image The_Darkwing_Duck · Aug 24, 2017 at 01:15 PM 0
Share

Wonderful!!! Thanks, don't even have to use code for this!

avatar image DawnosaurDev · Dec 16, 2017 at 12:01 PM 0
Share

Super helpful thanks!!!

avatar image Bunny83 · Dec 16, 2017 at 02:45 PM 0
Share

I've accepted the answer since the OP wasn't online for the last 3 years. I'll also lock the comments since the question got bumped for no reasons too often.

avatar image
6

Answer by Eric5h5 · Feb 03, 2011 at 03:29 AM

You can't use IgnoreCollision after objects have already collided, because the collision has already occurred, and therefore can't be ignored...it can't go back in time to the previous frame and be applied retroactively. The idea is to use IgnoreCollision beforehand, such as when the objects are instantiated.

Or you can just use collision layers and not bother with IgnoreCollision at all.

Comment
Comments Locked · 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
0

Answer by Devlus · Feb 03, 2011 at 04:56 AM

Another way you could do it, would be not make the objects have physics until right before the collision, so u could ray cast out and then add a collider or rigid body component, or what have you on collision with that ray, might be more confusing, but I think it would work... I think

Comment
Comments Locked · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why does my player object decide to ignore colliders whenever he feels like it? c# 1 Answer

Layers of collision in Unity (or something similar)? (C#) 1 Answer

Make a rigidbody collide with this rigidbody but not that one? 1 Answer

How to check if two objects are mutually ignoring collision? 0 Answers

Ignore collision for all except one 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