Quote: "Is there any way to do this with ray-casting? I imagine that you would need to use more than one ray-cast, then possibly use the heights (y-value) and the distance between them to determine the angle/slope of the incline. "
You are right !! and as Dia say, we can achieve that in lots of ways. This code snippet works in a matrix, but also can be adapted to Advance Terrain.
`Adjust the vehicle inclination with the terrain slope
create bitmap 1,50,50:for i= 1 to 1550:ink rgb(230,95,55),0:line rnd(60),i,i,rnd(130)
next i:blur bitmap 1,6:get image 1,10,10,50,50:delete bitmap 1
make matrix 1,10000.0,10000.0,25,25
prepare matrix texture 1,1,1,1
randomize matrix 1,350.0
update matrix 1
set ambient light 20
`The tank and the helper objects (this helper will be hide)
`we can do this without any helper, jus with coordinates
make object sphere 1,0
make object sphere 5,0
make object box 2,50,5,80:color object 2,rgb(10,50,10)
make object box 3,40,20,50:offset limb 3,0,0,0,25
make mesh from object 1,3 :delete object 3
add limb 2,1,1 :add limb 2,2,1
scale limb 2,2,20,40,120 :offset limb 2,2,0,25,20:offset limb 2,1,0,10,-20
color limb 2,2,rgb(0,10,0):color limb 2,1,rgb(0,30,0)
x#=500
z#=500
sync on
do
if upkey()=1 then x#=newxvalue(x#,a#,1) : z#=newzvalue(z#,a#,1)
if downkey()=1 then x#=newxvalue(x#,a#,-1) : z#=newzvalue(z#,a#,-1)
if leftkey()=1 then a#=wrapvalue(a#-0.5)
if rightkey()=1 then a#=wrapvalue(a#+0.5)
`checking height of two helpers
yb#=get ground height(1,object position x(1),object position z(1))
yb2#=get ground height(1,object position x(5),object position z(5))
`checking height of the tank
y#=get ground height(1,x#,z#)
`positioning helpers with the tank
position object 1,x#,yb#+40,z#
position object 2,x#,y#+30,z#
position object 5,x#,yb2#,z#
`turning
yrotate object 1,a#
yrotate object 2,a#
yrotate object 5,a#
`checking in front ot the tank
move object 1,80
`checking on one side (left)
move object left 5,30
`pointing the tank to the coords of the helper 1
point object 2,object position x(1),object position y(1),object position z(1)
`rolling the tank its height less helper height
roll object left 2,y#-yb2#
`camera behind the tank
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get ground height(1,cx#,cz#)+100.0
position camera cx#,cy#+200,cz#
tr#=tr#+0.1
rotate limb 2,2,0,tr#,0
point camera x#,y#,z#
sync
loop
Cheers.
I'm not a grumpy grandpa
