I never liked using the
lock object on command because it really just keeps the object at the origin of the world and displays it on the screen anyway, and as you pointed out, any pointing or positioning that needs to be relative to the camera is a little screwy. To fix all this, I wrote this function a while back to keep an object in the camera's view at all times. It's purpose is to completely replace
lock object on.
Here's the function:
function OrbitCamera(Camera,Object,XDist#,YDist#,ZDist#,XAng#,YAng#,ZAng#,ZDepthFlag)
position object Object,camera position x(Camera),camera position y(Camera),camera position z(Camera)
rotate object Object,camera angle x(Camera),camera angle y(Camera),camera angle z(Camera)
move object right Object,XDist#
move object up Object,YDist#
move object Object,ZDist#
pitch object down Object,XAng#
turn object right Object,YAng#
roll object left Object,ZAng#
if not ZDepthFlag then disable object zdepth Object
endfunction
The distances and angles passed into the function are all relative to the camera.
After calling this function to position the object, you can point it wherever you want to.
set display mode 1024,768,32,1
sync on
hide mouse
make object box 1,1,1,3
make object sphere 2,2
do
control camera using arrowkeys 0,1,1
`Place the box 20 units ahead of the camera in the middle of the screen
OrbitCamera(0,1,0,0,20,0,0,0,1)
`Point the box at the sphere
point object 1,0,0,0
sync
loop
end
function OrbitCamera(Camera,Object,XDist#,YDist#,ZDist#,XAng#,YAng#,ZAng#,ZDepthFlag)
position object Object,camera position x(Camera),camera position y(Camera),camera position z(Camera)
rotate object Object,camera angle x(Camera),camera angle y(Camera),camera angle z(Camera)
move object right Object,XDist#
move object up Object,YDist#
move object Object,ZDist#
pitch object down Object,XAng#
turn object right Object,YAng#
roll object left Object,ZAng#
if not ZDepthFlag then disable object zdepth Object
endfunction
Hope this is what you were looking for.
Edit: Just a thought, you might want to set ZDepthFlag to zero so the arrow you're trying to draw always appears over other objects...