Collision is shaky because you continuously move up the sphere and the cam as soon as it touches the terrain and move it back down as soon as it doesn't collide anymore, therefore you're continuously moving plus/minus a few units along Y#
The only way is to detect what it is the actual terrain height at sphere position and put sphere and cam there.
By casting a vertical ray with intersect object command from very high from terrain and to very low beneath it, you get the hit spot along Y# axis and can calculate the Y# position precisely .
Try this
Sync on
`Load All Media
Load Object "Terrain.x",1
Make Object Sphere 2,10
`Make Y# global in order to be seen outside the function
Global Y#
`Position the Object
Position Object 2,20,100,20
`Adjust frame rate to 60
sync rate 60
`The main loop
Do
`Call the controls
Controls()
`Call the height check of terrain at Sphere position
Heightcheck()
`Print value of terrain height
set cursor 0,0
print "Y#=",Y#
sync
loop
Function Controls()
If Upkey()=1 then move Object 2,2
If Downkey()=1 then move object 2,-2
If Leftkey()=1
turn object left 2,0.5
turn camera left 0.5
endif
If Rightkey()=1
turn object right 2,0.5
turn camera right 0.5
endif
endfunction
Function Heightcheck
X#=Object Position X(2)
Z#=Object position Z(2)
hitspot#=intersect object(1,X#,10000,Z#,X#,-10000,Z#)
Y#=10000-hitspot#
Position Object 2,X#,Y#,Z#
Position Camera X#,Y#+10,Z#
endfunction