Gravity without a rigidbody script for whoever can use it

Here is line of code used in a flight script on a youtube tutorial to keep the Flying object from passing through the terrain. I changed the > (greater then ) to a < (less then) and in doing so I created a very simple gravity without a rigidbody script.

function Update () {
   
     terrainHeightWhereWeAre = Terrain.activeTerrain.SampleHeight( transform.position );
       
        if (terrainHeightWhereWeAre < transform.position.y)
            transform.position = new Vector3(transform.position.x,
                                             terrainHeightWhereWeAre,
                                             transform.position.z);
       
   
}

Well, that’s not “gravity” so much as “lock you onto the ground”.