How do I make c# script to have a player not fall through a platform?

I want to have a basic platform and when the player (sphere) collides with the platform they do not fall through. I got that to work but when the player steps off of the platform they do not fall. How would i do that? (in c#)

Just add a rigidbody, and let it do the work.

Either that, or you read up a little bit on character controllers see:

Unity 3D - Rigidbody VS CharacterController [UnityQuickTips] - YouTube for a good guide

Add rigidbody to the player and colliders to both player and the platform.

An alternative I am working with is navmeshAgent Its a simple solution to a complex problem. If your looking for a dirty alternative for collision.