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
0
Question by LuminosityXVII · Mar 12, 2014 at 05:58 AM · physicstriggercollider 2d

2D colliders don't appear to be detecting each other

Alright, so I've got two game objects with 2D box colliders (one player-controlled and one unmoving) seem to be refusing to detect each other. I've got a script to destroy the unmoving object when the two come into contact:


 using UnityEngine;
 using System.Collections;
 
 public class DestroyOnContact : MonoBehaviour
 {
     void OnTriggerEnter2D (Collider2D other)
     {
         Destroy (gameObject);
     }
 }


I've tried colliding them with Is Trigger turned on for both objects' colliders, I've tried turning off Is Trigger and using OnColliderEnter2D, and I've even tried just using OnTriggerEnter/OnColliderEnter without the 2D bit. They just refuse to interact with each other at all. I'm probably missing something simple, but I can't think of any possibilities that I haven't tried. Oh, and they are on the same layer, in case that's relevant/important. And at the same Z position, though from what I understand that shouldn't matter.

Comment
Add comment · Show 4
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 Nodgez · Mar 12, 2014 at 11:41 AM 0
Share

Can you take a screenshot of the inspector please, i think i might know what's up

avatar image LuminosityXVII · Mar 12, 2014 at 08:15 PM 0
Share

Sure thing, here's one for each object:

Album

avatar image Nodgez · Mar 12, 2014 at 08:55 PM 0
Share

It appears you have a collider on the object and then another on a child object(let me know if I'm wrong). Is there a chance that either the child object hasn't got a rigid body or that the child object is the object being destroyed leaving just the parent object and with it the image of the wolf.

avatar image LuminosityXVII · Mar 13, 2014 at 12:04 AM 0
Share

Nope, the only child object involved is a camera. No colliders or rigidbodies there.

I actually sort of figured it out; for some reason I have to turn off Is $$anonymous$$inematic for both objects (which of course also requires setting gravity scale to 0 so they don't fall off the screen). Now, though, I've got another problem: the colliders appear to have padding around them, reacting to each other before they actually touch. Not sure what to make of that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hamcav · Mar 12, 2014 at 12:58 PM

From Unity Script Reference:

"Note that trigger events are only sent if one of the colliders also has a rigidbody attached."

So you need at least one rigidbody attached to one of you gameobjects. That should fix your Problem :D

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 LuminosityXVII · Mar 12, 2014 at 08:07 PM 0
Share

Unfortunately not. Sorry, forgot to mention, but both objects have rigidbody2Ds attached, and I tried it with only one having a rigidbody2D and, when that failed, with just regular rigidbodies. None of it worked.

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

22 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

Related Questions

overlapsphere to destroy NPCs on exit 1 Answer

Is there a way to deny an exit (and therefore OnTriggerExit) 2 Answers

Collider/trigger collision causing physics glitch 0 Answers

Box Collider (Trigger) Efficiency Question 0 Answers

Collider Lifts me off Ground ??? And I'm afraid of heights !!! 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