What is the code for detecting a collision?

I have the problem that my character keeps clipping through walls. I’ve come up with the solution that, if I lower the speed of the character upon collision with the wall, it won’t clip through.

I’ve looked through the Unity scripting reference, but I’m having a lot of trouble finding which code I’m supposed to use. What is the code for detecting a collision?

OnCollisionEnter?

Here is the documentation:

Link Edited : OnCollisionEnter