Hallo friends....there is an easy way to collide... (simulate collision) with the terrain or matrix.... and we just have to know the matrix or terrain heithe around us to decide to slide forcing the camera (player object )to go around or stop if not posible to go.
Have a look to this litle example.
Cheers.
[/code]
autocam off
sync on
ink rgb(0,100,0),1:box 0,0,50,50
ink rgb(0,200,0),1:box 10,10,40,40
ink rgb(0,130,0),0:set cursor 0,0
print
print "CHAFARI"
print "CHAFARI"
print "CHAFARI"
get image 1,0,0,50,50,1
`We make the terrain
`_______________________
make matrix 1,2000,2000,50,50
prepare matrix texture 1,1,1,1
randomize matrix 1,50
for i= 10 to 40
set matrix height 1,i+rnd(5),i+rnd(5),rnd(300)
next i
update matrix 1
`starting position
x#=300
z#=300
`________________________
do
//camera controls
if upkey()=1 then x#=newxvalue(x#,a#,0.3) : z#=newzvalue(z#,a#,0.3)
if downkey()=1 then x#=newxvalue(x#,a#,-0.3) : z#=newzvalue(z#,a#,-0.3)
if leftkey()=1 THEN x#=NEWXVALUE(x#,a#-90,0.3):z#=NEWZVALUE(z#,a#-90,0.3)
if rightkey()=1 THEN x#=NEWXVALUE(x#,a#-90,-0.3):z#=NEWZVALUE(z#,a#-90,-0.3)
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
y#=get ground height(1,x#,z#)+5
`camera limits
if cam#<=290 and cam#>180 then cam#=290
if cam#>=70 and cam#<180 then cam#=70
rotate camera cam#,a#,0
`we make sure the player walk around
`_____________________________________
xd#=get ground height(1,x#+30,z#)
xi#=get ground height(1,x#-30,z#)
zf#=get ground height(1,x#,z#+30)
zb#=get ground height(1,x#,z#-30)
if xd#>y#+20 then dec x#,0.3
if xi#>y#+20 then inc x#,0.3
if zf#>y#+20 then dec z#,0.3
if zb#>y#+20 then inc z#,0.3
position camera x#,y#,z#
`_____________________________________
sync
loop
[code]
oh my god