Hi Graysire. This is easy, just comparing points in front and on one side of you object. Take a look to this example, and you can adjusted to your needs.
set display mode 800,600,32
rem TEXTURE ))))))))))))))))))))))))))))))))))))))))))))
ink rgb(100,200,100),0
box 0,0,100,100
ink rgb(100,100+rnd(155),100),0
for i= 1 to 2000
dot rnd(100),rnd(100)
next i
get image 1,0,0,100,100,1
rem ))))))))))))))))))))))))))))))))))))))))))))))))))))
autocam off
sync on
set ambient light 30
position light 0,100,60,100
make light 1:position light 1,100,60,100
make matrix 1, 200,200,3,3
prepare matrix texture 1,1,1,1
make object box 100,0.3,10,0.3
offset limb 100,0,0,5,0
make mesh from object 1,100:delete object 100
for i= 1 to 30
make object box i,5,3,5:color object i,rgb(rnd(255),rnd(255),rnd(255))
add limb i,1,1
position object i,25+rnd(150),0,25+rnd(150)
yrotate object i,rnd(180)
set shadow shading on i,0,100,1
next i
position camera -110,110,-110
point camera 0,0,0
new:
randomize matrix 1,40
update matrix 1
do
set cursor 0,0
print "Press space to change terrain"
print "Use mouse/arrokey to fly camera"
for i= 1 to 30
yy#=get ground height(1,object position x(i),object position z(i))
y#=object position y(i) rem object position y()
position object i,object position x(i),yy#,object position z(i)
`getting new x,y,z in front of every object
move object i,5
y2#=get ground height(1,object position x(i),object position z(i))
x2#=object position x(i)
z2#=object position z(i)
`aceleration in the case object goes down
if y2#<y# then sp#=0.02 else sp#=0.0 rem aceleration going down
`reseting position
move object i,-5
`getting new side height of every object
move object left i,5
y3#=get ground height(1,object position x(i),object position z(i))
`reseting position
move object right i,5
`pointing and rolling every object
point object i,x2#,y2#,z2#
roll object left i,(y#-y3#)*12 `(actual_y - side_y)*12 I need a better solution...
rem object movements
turn object left i,0.2
move object i,0.03+sp# rem moving objects + speed depending on terrain slope
if object collision(i,0) then turn object right i,0.5
next i
if spacekey() then goto new
control camera using arrowkeys 0,0.3,0.3
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
if leftkey() then move camera left 0.3
if rightkey() then move camera right 0.3
sync
loop
I'm not a grumpy grandpa
