your issue is the way you're shooting your
intersect object ray. instead of shooting it down from the player's current height (actually you're shooting it upwards. down is minus, not plus) you should shoot it from way up in the sky to way down below 0. this will be sure to hit the track, if the player is over it. then grab the actual height by subtracting the result of the
intersect object (which returns the length of the ray from start to intersection) from the original height.
Rem Project: RoadRage
Rem Created: Friday, October 01, 2010
set display mode 1024,768,32,1
sync on
autocam off
hide mouse
set dir "media\world"
load image "land-track-tex2.bmp",1,1
load image "mud1.png",2
remstart
make object terrain 1 ` create the terrain object
set terrain heightmap 1, "land-test.bmp" ` set the heightmap
set terrain scale 1, 4, 0.4, 2 ` set the scale
set terrain split 1, 16 ` split value by 16 * 16
set terrain tiling 1, 4 ` detail map tiling
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5 ` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain texture 1, 1, 2 ` base and detail texture
build terrain 1
remend
set ambient light 100
position camera 1381,650,-783
load object "racetrack1.x",2
fix object pivot 2
position object 2,383,75,3050
texture object 2,2
set dir ".."
set dir "bike"
load object "bike.x",3
yrotate object 3,180
fix object pivot 3
position object 3,1381,800,-783
accel#=.1
speed#=0
drag#=0
make object sphere 4,22500
set dir ".."
set dir "sky"
load image "vd1.dds",4,0
texture object 4,4
set object 4,1,1,0,0,1
xrotate object 4,90
zrotate object 4,90
position object 4,383,0,3050
loop object 3,5,25
set dir ".."
set dir "sounds"
load music "roadrash_pc.mid",1
load music "roadrashredwoodforest.mid",2
load sound "car.wav",1
set sound speed 1,2000
loop music rnd(1)+1
set music volume 1,50
set music volume 2,50
set camera range 1,20000
falling as boolean //this keeps track of whether the player is currently falling
falling = 0 //set it to false so that we don't automatically lose the game
//first, set the player on the track
position object 3, object position x(3),2000-intersect object(2, object position x(3),2000,object position z(3), object position x(3),-2000,object position z(3)),object position z(3)
do
x#=object position x(3)
z#=object position z(3)
y#=object position y(3) //get the y value, we need to check it against stuff and then change it later
//intersect object returns the distance from the starting point to the intersection point
//since the ray is pointing downwards, the y value should equal what the top point of the ray is
//minus the distance from there to the track. instead of shooting directly from the player, shoot
//from way above it, so that when he goes up a hill, the startpoint of the ray is still above the track
//shooting downwards at it. if the player drives off the track, intersect object() returns 0, so
//when that happens you should add falling code. to do that, i've added another step here:
//instead of just setting y# to the height value, i'm first seeing whether the player is still on the
//track. if so, set his height to the track. if not, fall.
if not falling //make sure the player is not currently falling
//if he's not then he's still on the track and we can stick to it:
ty# = intersect object(2,x#,y#+20,z#,x#,y#-20,z#) //collect ray-to-object distance
else
ty# = 0 //otherwise make sure we keep falling
endif
//now check whether we should set the height to ty#, or just fall
if ty#>0 //if the ray hits the track, meaning the player is over the track
y# = y#+20 - ty# //set it to the height of the track (ray start minus dist from ray start)
else
dec y#, 2 //if the player is off the track then fall
falling = 1 //and set the player to falling
endif
`ground#=get terrain ground height(1,object position x(3),object position z(3))
text 0,0,"FPS "+str$(screen fps())
text 0,12,"Ground Height "+str$(y#)
text 0,24,"Bike height "+str$(object position y(3))
text 0,36,"x "+str$(x#)
text 0,48,"z "+str$(z#)
if sound playing(1)=0
play sound 1
endif
if upkey()=1
if speed#<4.5
inc speed#,.005
inc drag#,speed#/4
inc rev#
set object speed 3,speed#*10
set sound speed 1,2000*((speed#*4)+1)
endif
ENDIF
if downkey()=1
if speed#>0
dec speed#,.04
dec drag#,speed#/4
set sound speed 1,2000*((speed#*4)+1)
endif
if speed#<0
speed#=0
drag#=0
endif
ENDIF
rotate limb 3,0, 0,0,0
if leftkey()=1
if speed#<.5
slowturn=2
else
slowturn=0
endif
dec rot#,speed#+slowturn
yrotate object 3,rot#
rotate limb 3,0, 0,0,-8
inc left
ENDIF
if rightkey()=1
if speed#<.5
slowturn=2
else
slowturn=0
endif
inc rot#,speed#
yrotate object 3,rot#
rotate limb 3,0, 0,0,8
inc right
ENDIF
if speed#>0
dec speed#,.001
set sound speed 1,2000*((speed#*4)+1)
endif
position object 3,x#,y#,z#
move object 3,speed#
yrotate camera wrapvalue(rot#)
set camera to follow x#,y#,z#,rot#,2,2,1.5,1
sync
LOOP
i added a few variables to make the player able to fall of the track too.
edit: a little choppy, but it actually works now. and also the bike tilts.

Remember those old guys? They made epic renders, I think one of them was called DaVinci, and all they used was MS Paint. Sometimes it's just skill....