Best way to stop character from going off the edge?

I don’t want the character to go off the edge. These are some ideas, I had:

  • Use a raycast to check for ground in front of the character.
  • Use a nav mesh somehow.

What would you recommend? What is the best way to stop the character from going off the edge?

I might just place a collider at the edge.