To make your character following the terrain Y, you can do this :
...
// If your character has height of 0.5 (don't remember if ObjectSphereCast use radius or diameter), performs raycast
ObjectSphereCast( 0, GetObjectX(CharacterID), GetObjectY(CharacterID), GetObjectZ(CharacterID), GetObjectX(CharacterID), GetObjectY(CharacterID)-1, GetObjectZ(CharacterID), 0.5 )
if (GetObjectRayCastNumHits()=0) // if no collision under, character is falling
MoveObjectLocalY(CharacterID,-0.25) //-0.25 per frame
else // if collision
newY#=GetObjectRayCastY( 0 )
// Update Character Y
SetObjectPosition( CharacterID, GetObjectX(CharacterID), newY#, GetObjectZ(CharacterID) )
endif
...