• 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
Question by Topthink · Sep 04, 2017 at 04:50 PM · collisiontriggercollidersobjectsdetection

How To: One collider for detection; one for collision.

This is a general question so there really isn't any code to add.

I have a number of objects that travel along a terrain. These are primitive cylinders that are my game objects/tokens/units. I need to have each unit have both a combat radius/distance and a detection radius/distance. These are all NavMeshAgents.

Combat distance/radius: This is equal to touch...if it touches an enemy, there is combat (I can code this with a collider, no problem).

Detection distance/radius: This goes out a ways...if an enemy moves within a certain distance of a friendly unit then it "appears" visible to the friendly unit (again, no problem, I can code this with a collider).

HERE's the PROBLEM! I don't know how to add them BOTH to the same friendly unit. I've been doing some research on how to add two colliders to the same object that each has different functions. I'm trying different combinations but I haven't found anything that works yet. Do I add another object to the main object (as in a parent/child) or do I add a second collider to the same object?

I can't really find anything on point (you don't need to do my research for me) but I need a starting point where I might find a solution to my problem.

Thanks in advance.

Comment

People who like this

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

Answer by ollie_payne · Sep 04, 2017 at 05:07 PM

You could attach a child object to the neccessary object, zero the position, and add the second collider onto that, with its own neccessary script etc. This is really the only way about this unless you want to create a script which compares distances between relative objects using Vector3.Distance(), or, Vector2.Distance() to complete the actions you require. Hope this helps.

Comment

People who like this

0 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 Topthink · Sep 04, 2017 at 05:12 PM 0
Share

Yes, it helps a lot. It gives me a good direction to go in and many things I can eliminate.

I've just (earlier today) added my first child object to another in the hopes that this would be a solution but I've got some bugs to work out.

I appreciate that you took the time to help me and I'll work on this for a bit.

avatar image Topthink · Sep 04, 2017 at 06:02 PM 0
Share

Works like a charm.

I couldn't figure out how to set up the child collider at first but once I set up the child collider layer to ignore raycasts it worked perfectly.

Wow. I'm really excited by this. It takes me a large step forward in my project.

Thank you kindly for your help.

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

113 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 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 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 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 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

Precise Collision Detection 0 Answers

Speed/trigger only working once 0 Answers

OnTriggerEnter2D not Working 0 Answers

Target touching enemy collision 1 Answer

Adds too many points to the score? 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