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 /
This question was closed Sep 06, 2017 at 08:46 PM by xeetsh for the following reason:

Other

avatar image
0
Question by xeetsh · Jun 03, 2015 at 07:02 AM · unity 52dcollisiononcollisionenter

testonCollisionEnter2D testwon't testget called on collison

After one hour of debuging im a little desperate and have to ask for help.

So in my 2D game I have two objects. One has a polygon collider and the other has a box collider. Triggers are switched off.

alt textalt text

Both objects have a Rigidboyd 2D attatched. Is Kinematic is switched off.

alt textalt text

The second object (the right screenshots) has 5 children attatched (This shouldn't be of importance as the collision only happens between the parent objects but who knows) Here is a screenshot of one child object. They are all identical.

alt text

My code (C#) (attatched to the second (right screenshots) object):

void onCollisionEnter2D(Collision2D other) { Debug.Log("attack"); }

I hope these are all important informations. I read through many posts with the same problem but it seems like all called the methode in a wrong way or have their colliders as triggers or their rigidbodys set to kinematic.

I hope you can help me. Thank you so much!

And sorry for my bad english im learning it at the moment.

Comment
Add comment · Show 1
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 Andres-Fernandez · Jun 03, 2015 at 07:03 AM 2
Share

Check the spelling its OnCollisionEnter2D (first letter is capital O).

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by zeppike · Jun 03, 2015 at 08:56 AM

All unity methods start with uppercase :) Use OnCollisionEnter2D() instead.

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 xeetsh · Jun 03, 2015 at 01:29 PM 0
Share

Wow! It really was that easy. I better don't tell you how long i debuged this or how long i read through forum posts (that only maybe had the same problem :))

Thank you!

avatar image
0

Answer by BumblingIdiot · Jun 03, 2015 at 03:05 PM

The method is spelled wrong. C# uses camel case with an upper case letter at the start unlike other languages like java. Otherwise might be to do with the is trigger being ticked on your child objects. Try temporarily disabling them if just changing the method spelling doesn't work?

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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to access a prefab's boolean property through collision (with the same Prefab but different Instance)? 1 Answer

Checking for collision with 2D objects/sprites 3 Answers

Button Enabling/Disabling using Collision Triggers? 1 Answer

How to make two objects collide without bouncing 2D 0 Answers

2D platformer. Let player slide under object. 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