this way might be more useful!
press upkey for a bit to get the cube on top of the other object, that is how to do the get ground height off an object. The control's are the same, both cubes are spining, and they never crash!
`///////////////////////////
`Created by CyberLuke
`///////////////////////////
`basic stuff
hide mouse:sync on:sync rate 0:cls:backdrop on:color backdrop rgb(50,50,50):autocam off
`make stuff
make object box 1,200,100,400
make object cube 2,80
make object plain 3,2,500
hide object 3
`make basic level
make matrix 1,1000,1000,5,5
position matrix 1,0-500,0-200,0-500
`color stuff
color object 3,rgb(255,0,0)
color object 2,rgb(0,255,155)
color object 1,rgb(0,0,255)
`line stuff
xrotate object 3,90
fix object pivot 3
set object rotation ZYX 3
`variables
cameraxa#=20
cameraya#=180
dist#=0-400
Xangle#=0
Yangle#=0
c=0
do
text 0,0,"Your getting an amazing "+str$(screen fps())+" FPS!"
inc c,controlkey()*10
color object 1,rgb(c,c*1.2,255)
`fix mouse
position mouse 320,240
`handle zooming in and out
if mouseclick()=1 then inc dist#
if mouseclick()=2 then dec dist#
`mouse look
Yangle#=wrapvalue(Yangle#+2*(leftkey()-rightkey()))
Xangle#=wrapvalue(Xangle#+2*(downkey()-upkey()))
cameraxa#=wrapvalue(cameraxa#+mousemovey())
cameraya#=wrapvalue(cameraya#+mousemovex())
`position camera
camx#=newxvalue(0,cameraya#,dist#*cos(cameraxa#))
camy#=newyvalue(0,cameraxa#,dist#)
camz#=newzvalue(0,cameraya#,dist#*cos(cameraxa#))
position camera camx#,camy#,camz#
`point camera at box
point camera 0,0,0
`rotate
rotate object 3,Xangle#,Yangle#,0
rotate object 1,object angle x(1)+1,object angle y(1)+2,object angle z(1)+1
rotate object 2,object angle x(2)+2,object angle y(2)+1,object angle z(2)+2
`limit x angle
if Xangle#>90 and Xangle#<180 then Xangle#=90
if Xangle#<270 and Xangle#>180 then Xangle#=270
`call special position function
cube position(1,2,Xangle#,Yangle#)
sync
loop
function cube position(cubenum,objnum,Xangle#,Yangle#)
dist#=(object size(cubenum)+object size(objnum))
set object collision on cubenum
set object collision on objnum
set object collision to polygons cubenum
set object collision to polygons objnum
dec#=3
do
x#=newxvalue(object position x(cubenum),Yangle#,dist#*cos(Xangle#))
y#=newyvalue(object position y(cubenum),Xangle#,dist#)
z#=newzvalue(object position z(cubenum),Yangle#,dist#*cos(Xangle#))
position object objnum,x#,y#,z#
dec dist#,dec#
inc dec#,0.01
if object collision(cubenum,objnum)=1 then exit
loop
set object collision off cubenum
set object collision off objnum
endfunction
www.CyberLuke.com