Slight mod to above code so you place cubes at matrix tiles properly. It will work whatever camera angle is aswell.
Sync On: Sync Rate 60:Autocam Off
global matx#=0
global maty#=0
global matz#=0
global mattilex=0
global mattilez=0
mw=200 : md=200 : mxd=10 : mzd=10
dim m(mxd,mzd)
Make Matrix 1,mw,md,mxd,mzd
Position Camera 100,90,-80
Point Camera 100,0,100
Make Object Cube 1,20
Ghost Object On 1
NewCube=11
Position Object 1,10,10,10
Do
mx=mousex()
my=mousey()
if matrix_tile(mx,my,1,mw,md,mxd,mzd) = 1
set cursor 0,0
print "X = ";matx#
print "Y = ";maty#
print "Z = ";matz#
print "Tile X = ";mattilex
print "Tile Z = ";mattilez
tilex#=mattilex*(mw/mxd)+(mw/mxd/2)
tiley#=10
tilez#=mattilez*(md/mzd)+(md/mzd/2)
position object 1,tilex#,tiley#,tilez#
show object 1
if mouseclick()=1 and m(mattilex,mattilez)=0
Clone Object NewCube,1
Position Object NewCube,tilex#,tiley#,tilez#
Ghost Object Off NewCube
NewCube=NewCube+1
m(mattilex,mattilez)=1
endif
else
hide object 1
endif
Sync
Loop
function matrix_tile(msx,msy,m,mw,md,mxd,mzd)
matpx#=matrix position x(m)
matpy#=matrix position y(m)
matpz#=matrix position z(m)
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
t=0
for f=0 to 5000 step 2
pick screen msx,msy,f
xx#=get pick vector x()+cx# : yy#=get pick vector y()+cy# : zz#=get pick vector z()+cz#
if xx# > matpx# and xx# < (mw + matpx#) and zz# > matpz# and zz# < (md + matpz#)
hh#=get ground height(m,xx#-matpx#,zz#-matpz#)
vv#=yy#-hh#-matpy#
if vv# < 0
for g=f to f-10 step -1
pick screen msx,msy,g
xx#=get pick vector x()+cx# : yy#=get pick vector y()+cy# : zz#=get pick vector z()+cz#
if xx# > matpx# and xx# < (mw + matpx#) and zz# > matpz# and zz# < (md + matpz#)
hh#=get ground height(m,xx#-matpx#,zz#-matpz#)
vv#=yy#-hh#-matpy#
if vv# >= 0
t=1
matx#=xx#
maty#=yy#
matz#=zz#
mattilex=int((xx#-matpx#)/(mw/mxd))
mattilez=int((zz#-matpz#)/(md/mzd))
exit
endif
endif
next g
if t=1
exit
endif
endif
endif
next f
endfunction t
Boo!