Do something when 2D character hits game object

Hi,

I’m using Unity 5.5. I have built a simplistic 2D scene, using the 2D Standard Assets. In my scene, I have a couple of platforms, a CharacterRobotBoy player, and a Sphere. Initial setting untouched.

What I want to do is perform some action (Debug.Log for example) when the player moves the character into the sphere. I followed the instructions there to the letter. However, the OnControllerColliderHit method is never called (be it because the character collides with the sphere or with the platform).

I added a Start() and an Update() method to my script with Debug.Log’s in it: they print stuff, so my script is correctly found. I quadruple-checked the spelling of the OnControllerColliderHit method, also.

Any suggestion appreciated!

Have a separate object for collisions, and have on its script an OnCollisionEnter method

First add a ridgidbody 2D component to your platform, character and sphere.

Set gravity in your platform’s ridgidbody component to zero.

Then Add a box/circle collider to your platform, character and sphere.

Then add a script to your player and use OnCollisionEnter2D() function and code the logic of what you want your player to do when he collides with any gameobject.