Here's some code I wrote based on a function from the Code Archives:
This function is to place an object, but it's easy to modify to just return the coordinates in 3D space. As for clicking on 2D buttons also, just ignore these 3D coordinates when the mouse pointer is over buttons and do things the normal way.
; ----------------------------------------------------------------------------- ; Positions an entity in 3D from given 2D coordinates Function PositionEntityFrom2D(usecam,entity,x2d#,y2d#,height#=0,camZoom#=1) gw=GraphicsWidth() gh=GraphicsHeight() x#=-((gw/2)-x2d) y#=(gh/2)-y2d parent=GetParent(entity) EntityParent entity,usecam z#=Abs(EntityZ(entity)) div#=(gw/(2/camzoom))/z x=x/div y=y/div ;z distance determined by a straight line from camera, through xyz coordinates, to height TFormPoint x,y,z,usecam,0 y3d#=height x3d#=TFormedX() z3d#=TFormedZ() EntityParent entity,parent PositionEntity entity,x3d,y3d,z3d End Function ;-----------------------------------------------------------------------------
This function is to place an object, but it's easy to modify to just return the coordinates in 3D space. As for clicking on 2D buttons also, just ignore these 3D coordinates when the mouse pointer is over buttons and do things the normal way.