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 ronronmx · Jan 30, 2011 at 06:39 PM · collisiononcollisionenter

Checking for collision of another gameObject with another trigger

I hope my title isn't too confusing...basically what I want to do is check if "Object Collision A" collided with "Trigger B" from a script attached to "Object C". So both "Object A" and "Trigger B" don't have any scripts attached to them, only "Object C" does.

Thanks in advance!

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 Goody! · Jan 30, 2011 at 07:07 PM

You can test in script against either the name of the object or the tag. Do a search for collider/ name/tag in the unity docs for how.

But you may a well attach that same script to each trigger. Then I think u can do a if this.name "triggername" and collider.name then do whatever.

Comment
Add comment · Show 4 · 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 ronronmx · Jan 31, 2011 at 12:08 AM 0
Share

Thanks for your answer Goody, I know it would be much easier to attach the script to each Trigger, but if I'm gonna have let's say 100 triggers out there, I would rather check for collision from 1 main script. I know how to test in script against the object name or tag, but how do I test for collision between Object A and Object B from Object C? Basically what i need to do is something like this:

if (ObjectA.Collider collides with ObjectB.Collider) {doSomething()}...but neither ObjectA and ObjectB have this script attached to them.

avatar image Goody! · Jan 31, 2011 at 07:36 PM 0
Share

You can have just one script on all of the triggers then test which of the triggers is being triggered and act accordingly, i believe. Like, if This.name == triggerA and collider.name == this then do whatever.

avatar image Goody! · Jan 31, 2011 at 07:38 PM 0
Share

If you have that many triggers I'm guessing you are going to need to manage them anyways.

avatar image reptilebeats · Feb 24, 2012 at 11:16 PM 0
Share

bit late but you will have to use update not oncollision as the oncollision is for what ever that script is on. so if u collide with it and the script is on something else it aint gunna do anything because the function cant run, hence its cheaper to use on collision but more but a bit more annoying

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

1 Person is following this question.

avatar image

Related Questions

Rigidbody not calling OnCollisionEnter 1 Answer

OnCollisionEnter called once even with multiple contacts 1 Answer

Objects in my scene are not responding to OnCollisionEnter 0 Answers

Using collision with Vector3.MoveTowards 3 Answers

Unity3D Playing Two Sounds - OnCollision 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