Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 aikitect · Jan 27, 2013 at 02:56 AM · charactercontrollercollision detectiononcollisionenter

Why does OnCollisionEnter not work between a character controller and a rigidbody?

I am building a game where I have a weapon that shoots a projectile (with a collider and rigidbody), and an enemy with a character controller. In the enemy script, I have a OnCollisionEnter function that detects collisions between the projectile and the enemy.

When I shoot the projectile, it simply bounces off the enemy (so the collider is working). However, the OnCollisionEnter function never executes.

Is there any reason why the collision would not be detected? The strangest part is that the collisions were working previously and now they don't for some unknown reason.

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 FL · Jan 27, 2013 at 12:46 PM 0
Share

The enemy has a collider? Did you mark both colliders as non-trigger?

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by aikitect · Feb 12, 2013 at 01:14 AM

I used OnControllerColliderHit and it works fine now.

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
avatar image
0

Answer by JoeStrout · Jan 06, 2014 at 04:21 AM

That's not a general solution, though -- OnControllerColliderHit only fires when your character controller moves into something. It won't detect, for example, when your character is just standing there and gets shot by something.

I've just discovered this issue myself, and I'm still looking for a solution.

Comment
Add comment · Show 2 · 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 DanJC · Jan 29, 2014 at 11:43 AM 1
Share

Well, why not both?

OnControllerColliderHit() to handle when your character bumps into something.

OnCollisionEnter() to handle when something bumps into your character.

I just tried this, appears to be reliable. However I also find that the object with the CharacterController component also needs to have a Capsule Collider component for the OnCollisionEnter() calls to work. I would have thought that wasn't necessary, since the physical behaviour is the same either way, but there you go.

avatar image JoeStrout · Jan 29, 2014 at 07:59 PM 1
Share

Yes, that's essentially what I've ended up doing: adding a separate Capsule Collider component. I sized $$anonymous$$e slightly bigger than the CharacterController, so that it will actually hit stuff, but I guess with your technique (implementing both callbacks) that might not be necessary.

avatar image
0

Answer by maminakyrtka322 · Sep 02, 2020 at 09:59 PM

Got same problem, OnControllerColliderHit works, colliders working, but OnCollisionEnter never executes. No info in whole internet( If you find a solution - pls tell me

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
avatar image
0

Answer by MultidimensionalShow · Aug 21, 2021 at 11:32 PM

Place a second collider on the object you want your player to collide with and set it as a trigger.

Detect the collison FROM the object, checking the tag of the colliding object ( the player in this case ).

Then handle as needed.

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

13 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

Related Questions

Enemy with character controller has inconsistent hit detection 1 Answer

colliders not working for unknown reason 1 Answer

Character not moving on slopes 1 Answer

Finding an object is within an another 3 Answers

Weird Collision Detection with a Cube and OnCollisionEnter 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