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
1
Question by Matthew Dennis · May 16, 2011 at 11:51 AM · gameobjectcollidercircletwo

2 Colliders on 1 gameobject

Hello,

I want to be able to have 2 colliders on a gameobject but both being affected by 2 different actions.

Meaning:

Imagine a circle in the air(with 2 circle colliders on). The first collider will be 5x bigger than the circle, the second collider being 2x bigger than the circle. Now if the player collides with the first circle, it will spawn a 'missile' that will fire at the circle and if that 'missile' collides with the second collider, it will destroy the circle and itself. How can i give a title to the two different colliders for the ability i am trying to do to function properly. Like giving that collider a tag or something.

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

2 Replies

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

Answer by GesterX · May 16, 2011 at 12:40 PM

I am 99% sure you could do this:

  1. Give your gameObject two empty child GameObjects
  2. Attach a different collider to each child object
  3. Write two scripts with your OnColliderEnter functions for each collider
  4. Attach each script to each child object

So in the end you would have:

-Parent GameObject with:
-Child A with Collider A (large collider) and Script A (missile spawning) attached
-Child B with Collider B (small collider) and Script B (destroy on collision) attached

Comment
Add comment · Show 2 · 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 Matthew Dennis · May 16, 2011 at 01:15 PM 0
Share

thank you, this was easier than the way i was planning on doing it. Only thing is i am working with a few prefabs, would this make a difference to anything?

avatar image GesterX · May 16, 2011 at 06:30 PM 0
Share

No worries glad to help. Depending on how you're using the prefabs you may need multiple ones.

avatar image
0

Answer by DeltaTwoZero · Feb 26, 2019 at 01:37 AM

What i would also consider is to create 1 script with 2 references (for each collider). Afterwards, you could use:

 GameObject  ChildGameObject1 = ParentGameObject.transform.GetChild (0).gameObject;
 GameObject  ChildGameObject2 = ParentGameObject.transform.GetChild (1).gameObject;
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

2 People are following this question.

avatar image avatar image

Related Questions

Destroying Game Object On MouseButtonDown + Distance Collision 0 Answers

Multiple Colliders Trigger problem 2 Answers

How do I get a single object to move? 1 Answer

Ignore Collider 0 Answers

how to move an object clone to mouse position, i dont understand ? 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