The smoothing isn't great but with some tweeking it should give you a system to point the camera at a target while keeping your player in view:
Rem Project: Camera
Rem Created: Tuesday, August 30, 2011
Rem ***** Main Source File *****
sync on
sync rate 60
`hide mouse
make matrix 1, 1000,1000,10,10
make object box 1, 20,10,30
position object 1, 0,5,0
facing# = 0.0
camrotate# = 0.0
rem add some 'target' objects
for obj=2 to 10
size#=5+rnd(10)
make object cube obj,size#
position object obj,rnd(1000)-500,size#/2,rnd(1000)-500
next
rem make a dummy object
make object cube 99,5
hide object 99
position object 99, 0,5,0
do
move object 1, (upkey()-downkey())*5
facing# = facing# + 1.5 * (rightkey()-leftkey())
yrotate object 1, facing#
if targ=0
if downkey()
set camera to follow object position x(1), object position y(1), object position z(1), facing#+180, 75, 50, 60, 1
else
set camera to follow object position x(1), object position y(1), object position z(1), facing#, 75, 50, 60, 1
endif
else
set camera to follow object position x(1), object position y(1), object position z(1), targang#, 75, 50, 60, 1
endif
targ = find_nearest()
if targ>0
tx#=object position x(targ)
ty#=object position y(targ)
tz#=object position z(targ)
targang#=atanfull(tx#-object position x(1),tz#-object position z(1))
else
tx#=object position x(1)
ty#=object position y(1)
tz#=object position z(1)
endif
dx#=object position x(99)
dy#=object position y(99)
dz#=object position z(99)
position object 99,dx#+(tx#-dx#)*.05,dy#+(ty#-dy#)*.05,dz#+(tz#-dz#)*.05
point camera dx#,dy#,dz#
sync
loop
function find_nearest()
mind#=100000
for obj=2 to 10
dx#=object position x(1)-object position x(obj)
dz#=object position z(1)-object position z(obj)
d#=sqrt(dx#^2+dz#^2)
if d#<mind#
mind#=d#
nearest=obj
endif
next
if mind#>100
nearest = 0
endif
endfunction nearest
EDIT: If you get more than 100 units away from any target it will go back to your player...
EDIT2: I'll try to take a look at your wait code later (should be working now!