Hi. Been up all night, and for some reason thought I'd make this.
What it does, is it gets the ground height of an object based on the position of the other object that you want to place, and positions it at the found ground height.
One advantage over a matrix though, is that it looks for the ground height from the position of the object that you want to place, allowing for the ground object, to have many different levels.
It also positions the object considering its size, so the base will always be on the ground, and not the objects centre.
I'm afraid I'm too tired to add comments to it, but its all pretty straight forward.
`Made by caffeine.
sync on
sync rate 32
autocam off
make object sphere 1,10
scale object 1,3000,1000,3000
color object 1,rgb(200,255,200)
make object cube 2,5
color object 2,rgb(255,200,200)
position object 2,0,600,0
do
if leftkey()=1
yrotate object 2,object angle y(2)-wrapvalue(4)
endif
if rightkey()=1
yrotate object 2,object angle y(2)+wrapvalue(4)
endif
if upkey()=1
move object 2,1
endif
if downkey()=1
move object 2,-1
endif
PositionObjectAtObjectHeight(2,1)
set camera to follow object position x(2),object position y(2),object position z(2),0,60,30,10,0
point camera object position x(2),object position y(2),object position z(2)
sync
loop
END
Function PositionObjectAtObjectHeight(objectnum1,objectnum2)
X#=object position x(objectnum1)
Z#=object position z(objectnum1)
Y#=object position y(objectnum1)
ObjectSizeY=object size y(objectnum1)
intersection#=intersect object(objectnum2,X#,Y#+ObjectSizeY,Z#,X#,Y#-100000,Z#)
if intersection#=0
objectheight#=0
else
objectheight#=ObjectSizeY+Y#-intersection#
endif
position object objectnum1,X#,objectheight#+ObjectSizeY/2,Z#
Endfunction
Now, time for some coffee.
Absent.