- Home /
Character Controller wont collide (not a trigger issue)
I have a cube set up as a non trigger and a character controller but OnControllerColliderHit is not working. I can get it to display a message if i use OnTriggerEnter when the cube is set up as a trigger but then the cube wont collide with anything as its now a trigger. There is also doesnt appear to be reason why this should not work but it doesnt.
void OnColliderEnter (Collision hit) { print("hit"); }
So a recap. OnTriggerEnter works but OnColliderEnter does not, nor does OnControllerColliderHit. This happens regardless of whether i have a rigidbody on anything or not so i am definitely missing something. All the other answers on the same subject when googling "character controller not colliding" unfortunately are not what i am looking for as they still dont work.
Thanks in advance!
Answer by whydoidoit · Feb 15, 2014 at 07:35 AM
OnCollisionEnter (not OnColliderEnter) won't be called unless there is a rigidbody attached.
OnControllerColliderHit will only be called if you move the character controller using SimpleMove or Move, while that move is occurring.
If you need more than this then you should add a rigidbody (set to isKinematic) and use OnCollisionEnter.
Answer by Kavorka · Feb 14, 2014 at 10:36 PM
I see the solution. I found it here.
You posted a generic link to the $$anonymous$$onoBehaviour class which every script derives from; that's not an Answer.
Yes it is because it says there that it is not OnColliderEnter, it is OnCollisionEnter. Thus answering the question of what is wrong with the enclosed code.
Yes it is because it shows the page where the names of all monobehaviour callbacks are listed. If you dont know them you can not search for them. A search for OnColliderEnter is empty.
Yes it is, for more people than the poster, because this is a very useful page that many have not yet found.
Have a nice day, the downvote really made me want to help out more here.
@CarltonSmith, I think what @$$anonymous$$avorka was suggesting (albeit in the most lazy way possible) is that you should check the spelling on your method. Try the following code:
void OnCollisionEnter(Collision collision)
{
Debug.Log("Collision Detected");
}
Here is a link to the documentation:
I had a strange issue with mono that was creating lots of red words where there shouldnt be red words. A reinstall of unity and this works fine. Thank you all folks. (All answers upvoted).
Your answer
![](https://koobas.hobune.stream/wayback/20220613133528im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Physics AddForce reduced when 3 objects are colliding 1 Answer
How to trigger different animations depending on where a gameobject collides? 1 Answer
OnCollisionEnter not working with CharacterController 1 Answer
OnCollisionEnter Push Object Problem 0 Answers
Collision Detection in Capsule Collider 0 Answers