Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 williambacon · Aug 15, 2015 at 07:08 AM · collision detection

2D Colliders Not Working

Hello, I'm pretty sure I've done everything right to make my objects collide but they dont! My Project is a 2d project and has 2d mode on My games is where i have the player in the middle of the screen and enemies come at him. I have a shield thats moves when you touch a side of the screen. I want it so the enemies collide with the shield and explode (destroy).The enemies are instantiated so i added this script onto the enemy:

 void OnCollisionEnter2D (Collision2D col)
 {
     //Check collision name
     Debug.Log("collision name = " + col.gameObject.name);
     if(col.gameObject.name == "Shield")
     {
         Destroy(this.gameObject);
     }
 }

}

And i put 2d ridgidbody's and 2d box colliders on the enemies and the shield. The ridgidbody's are not kinematic, the gravity is just turned off. If this is just a bug in Unity then should I restart the project? Any help is greatly appreciated! Thanks!

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 williambacon · Aug 14, 2015 at 01:45 AM 0
Share

no, thats why I'm confused because if I did get the debug.log then it would've just been a scripting error

avatar image Ekta-Mehta-D · Aug 14, 2015 at 08:00 AM 0
Share

that means they are not colliding. so OnCollisionEnter2D is not getting called.

avatar image williambacon · Aug 14, 2015 at 03:50 PM 0
Share

ok, how do I make it so they collide because right now they just pass through each other?

avatar image Harardin · Aug 15, 2015 at 07:22 AM 0
Share

Try to use on ColliionStay2D just to check. does it collide or not, it more sensitive then OnCollisionEnter

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Chrisasan · Aug 17, 2015 at 12:28 PM

IF they are passing through each other, then you need to toggle the IsTrigger flag on the collider to false, not checked. If Is Trigger is checked then you need to use OnTriggerEnter2D() rather than OnCollisonEnter2D()

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Diablo 3 style melee combat 2 Answers

Collision2D not detecting when playing is jumping 2 Answers

Did triggers inside loaded gameobjects break in a recent update? 0 Answers

I need your help I have a script to reload a scene if the player go on a unauthorized gameObject but the game freeze please help. 0 Answers

Make 2D projectile collide only from the outside 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