Well ....the little piece of code snipet I showed you, was just a example on how to start....the example editor has much more code to prevent this error you mention. Under the matrix there is a hidden object and then I use the comand PICK OBJECT to get the exact position. Have a look to more code of the editor program.
Every time the mouse is on the matrix, the sphere will reposition trying to find a correct vertex to set matrix height.
remstart
With the command [b]pick object[/b], we can see if the mouse (or other object coordinates) are on coordinates x, z of an object such as a rectangular matrix .....
With command [b]get pick vector x()[/b] we get exactly the position x,z that we are into this object.
remend
ink rgb(170,170,0),0
box 0,0,20,20
ink rgb(0,80,0),0
box 2,2,19,19
get image 1,0,0,20,20,1
sync on
make object plain 1,20,20:texture object 1,1:scale object texture 1,20,20
position object 1,10,-0.1,10
xrotate object 1,90
make object sphere 2,0.5:color object 2,rgb(255,0,0)
position camera -5,15,-10
point camera 10,0,10
do
ink rgb(255,255,255),0
set cursor 0,5:print tempx+1
print tempz+1
position object 2,tempx,0,tempz
null=pick object (mousex(),mousey(),1,1)
tempx=get pick vector x()+camera position x()
tempz=get pick vector z()+camera position z()
control camera using arrowkeys 0,0.1,0.1
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
if leftkey() then move camera left 0.1
if rightkey() then move camera right 0.1
position camera camera position x(),20,camera position z()
sync
loop
If you have more doubts do not hesitate to ask
Cheers.
I'm not a grumpy grandpa
