Yeah I was really sleepy this mornong. Like Ric said you are loosing loop time in your calculations as well. You need to compare the loop time as close as you possibly can to when you set the timer. Something like Ric's example. I'll try and see what I can come with when I'm home and awake this evening. Unless you get it working first.
[edit] There are still losses somewhere. But here is as close as I got without recalculating the distance left vs time left before 21.2 secs is up. It is really jumpy when I recalculate but it does get closer to the object.
endtimer# as double float
speedadj# as double float
begintimer# as double float
sync on : sync rate 0
autocam off
position camera 500, 10, 0
make object cube 1,2
make matrix 1, 500000, 500000, 20, 20
position object 1, 500, 10, 424000
speed = 20000
do
`[] keys move the cube
if keystate(26) = 1
if camera position z() < object position z(1)
Move camera speed*speedadj#
time# = (timer()-beginMovetime#)/1000
pos# = object position z(1)-camera position z()
if leftbrackpressed = 0
leftbrackpressed = 1
beginMovetime# = timer()
endif
endif
endif
set cursor 5, 5
print time#
set cursor 5, 25
print pos#
endtimer# = timer()
speedadj# = (endtimer# - begintimer#)/1000
begintimer# = timer()
sync
loop
The only loses I can see are from this point in the code
endtimer# = timer()
speedadj# = (endtimer# - begintimer#)/1000
begintimer# = timer()
this line speedadj# = (endtimer# - begintimer#)/1000 id being executed without affecting the lop time so it is causing somewhat of an error. And the double floats though very accurate lose a little accuracy but I don't think its enough to cause this.