Detecting Collision between Charctor controller and Box Collider

Hi, I am trying to detect a collision between my player (The character controller) and a wall object (the box collider). My code looks like this:

void OnCollisionEnter(Collision collision)
	{
		if(collision.gameObject.tag == "This")
		{
			Debug.Log ("Player Hit the Wall");
		}

The script is placed on the player, and the wall is tagged “This”. Anyone have ideas why nothing is showing up in the console when the player hits the wall?

Any help is much appreciated, I’m sure the answer is painfully obvious.

Thank you.

You need to use OnControllerColliderHit to detect collisions for character controller.

Sorry guys I figured out a work around that I’m going to use. I can’t detect collision between a character controller and box collider using OnCollisionEnter as HarshadK stated above, although I can’t seem to get OnCharacterColliderHit to work either. (possibly because I am not using a 3 function in my player’s movement code)

So what I have done instead, and it seems to be working so far, is attaching a box collider to my player aswell as a character controller. I also added a rigidbody to my wall as well as it’s own box collider. After doing this my original code seems to work just fine.

It’s not an ideal solution, and I’m sure there are a million better ways to do what I am doing but sure look, as long as it works right?

Thanks so much for helping me find an answer chaps, appreciate it.