I've seen this question asked a number of times before - how can you convert a 2d coordinate (say, the mouse position) into an object's coordinate in 3d space, given the object's z-position? Well, I had the need to figure it out for myself, so here is my basic solution ..... no pick object stuff - just a pure maths conversion.
`2-d to 3-d by Ric.
autocam off
position camera 10,10,0
fov#=60.0
sh#=screen height()
sw#=screen width()
screenaspect#=sh#/sw#
set camera fov fov#
z#=100.0
make object cube 1,2
do
screenx#=(z#-camera position z())*tan(fov#/2.0)/screenaspect#
screeny#=(z#-camera position z())*tan(fov#/2.0)
x#=((2*screenx#*mousex()/sw#)-screenx#+camera position x())
y#=-((2*screeny#*mousey()/sh#)-screeny#)+camera position y()
if upkey()=1 and z#>5 then dec z#,0.2
if downkey()=1 then inc z#,0.2
position object 1,x#,y#,z#
loop
Use the up and down keys to change the object's z-position. Should work for all screen sizes, fields of view and camera positions, but if you want to mess with camera rotations, then you'll need something more complex than this.