Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Jul 20, 2018 at 04:38 PM by bnwchbammer for the following reason:

Dumb mistake on my part, had an additional collider on the player object that was properly detecting collision on the player object.

avatar image
0
Question by bnwchbammer · Jul 20, 2018 at 03:52 PM · collisiontriggerchild

Detecting collision on an object and not its sister object.

Forgive me if this isn't really the proper way to describe this, but I'll try to clarify.

I have a parent GameObject that I'll refer to as the "capsule" object. It has two child GameObjects that each have their own Rigidbody and their own Trigger Box Collider. One child object has a script on it (it is the player script that handles movement and other player functions) and the other child object (referring to its sister in the title) is essentially a front bumper that extrudes out in front of the player object. When I call OnTriggerEnter in the player script it gets the Box Collider on the bumper object, which isn't what I want in this case. Is there a way to make sure OnTriggerEnter isn't firing off when its sister object is the one getting collision or should I be using a different function for this purpose?

Structure: alt text

Player: alt text

The bumper just has 3 components: Transform, Box Collider (trigger enabled), and Rigidbody.

Collider code on the player script:

 void OnTriggerEnter(Collider other) {
         //If a player walks into the powerup, grant the player the powerup
         if (other.gameObject.tag == "Powerup") {
 //etc
 }
 }

structure.png (3.7 kB)
player.png (62.0 kB)
Comment
Add comment · Show 2
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 aklgupta · Jul 20, 2018 at 04:08 PM 0
Share

Could you verify your script, or provide the necessary part of it here, as the box collider of one gameObject doesn't trigger any event for any other object. In fact I have been working to get the behavior that your are experiencing for a project of $$anonymous$$e, and just completed it a few hours ago, so I can confirm this is not the default behavior. Also, please confirm that the scripts have been added to the correct object.

avatar image bnwchbammer · Jul 20, 2018 at 04:17 PM 0
Share

Edited to include screenshots and code snippit.

1 Reply

  • Sort: 
avatar image
1

Answer by Shemamforash · Jul 20, 2018 at 04:18 PM

Hi there! Sounds like you want to use collision layers. In the Physics window you can see which collision layers interact with each other in a handy matrix. First you'll want to create two new layers, Bumper and Player (for example) and set the layer of the Bumper and Player objects accordingly. Then in the collision matrix in the Physics window, uncheck the box where the Bumper and Player row/column intersects. Now when you hit play, you'll find that OnTriggerEnter is no longer called, as the Physics engine is ignoring collisions between these two layers! Let me know if this helps at all :)

Comment
Add comment · Show 1 · 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 bnwchbammer · Jul 20, 2018 at 04:37 PM 0
Share

Alright, well I realized I made a silly mistake and accidentally had an additional collider on my player object, but this is useful information nonetheless, thanks!

Follow this Question

Answers Answers and Comments

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

C# Ignore Collision Trigger From Child 2 Answers

Player object still gets destroyed even when shields up 1 Answer

Scripting Child Objects Through Parent 1 Answer

Getting a Trigger's parent 1 Answer

Best way to detect specific collisions in child objects 2 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