Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by cj31387 · Jul 04, 2015 at 09:30 AM · 2dcollisiontriggermultipleignore

Ignore a collider when there are multiple ones?

I'm using the RobotBoy 2d standard asset for the basis of my 2d character. In another script if I execute something based on if the player collided with it, it will happen 2x because the RobotBoy by default has a Circle2d Collider and BoxCollider2d on it. Is there any way to ignore one of those specifically from executing when I do OnTriggerEnter in my other script?

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
Best Answer

Answer by Bluk · Jul 04, 2015 at 09:37 AM

You might want to look into Layer Collision matrix: http://docs.unity3d.com/Manual/LayerBasedCollision.html

Comment
Add comment · 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 cj31387 · Jul 04, 2015 at 11:39 AM 0
Share

Don't know how that will help because the gameobject that has the 2 colliders would only use one layer. Could you give me a example please?

avatar image Bluk · Jul 04, 2015 at 02:05 PM 1
Share

You can use a game object hierarchy. In the robotboy example, you could use the groundcheck child object to add a circle collider.

avatar image cj31387 · Jul 05, 2015 at 09:26 AM 0
Share

Yeah i already did that for my solution. I made a Child object with a box collider2d that works with my scripts. But I want to know how to specifically choose one collider on a gameobject that has multiple ones to do something and ignore the other colliders on the same gameobject.

avatar image Griffo · Jul 05, 2015 at 10:06 AM 1
Share

make an array of all the colliders on the GameObject ..

avatar image Bluk · Jul 05, 2015 at 01:43 PM 2
Share

It is kind of strange what you are trying to do, but if i understand well what you are trying to do, you could do this:

-If the colliders are of different types you can check if it is the right collider with something like:

 if(collider.GetType() == typeof($$anonymous$$eshCollider))

-If the colliders are of the same type, for example two BoxColliders, you could do something like:

 collider1 = GetComponents<BoxCollider>()[0];
 collider2 = GetComponents<BoxCollider>()[1];
 

And check if the collider is the one you want. Note that with this method, the order is deter$$anonymous$$ed by the inspector.

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

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

Related Questions

2D Collision detection to load level. 1 Answer

Trouble Descaling 2D object 1 Answer

Check if a Collider2D is hit by a Trigger Collider2D 1 Answer

Having problems with 2d collision triggers (javascript) 1 Answer

Collider2D/RigidBody2D not working 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