You must find the travel angle to your destination and give some moving speed to your object.
see this example:
______TOP_______:
rem Generic Template
_____INITIALIZE_____:
sync on:sync rate 60:sync
global Sw,Sh
rem Sw=1920:Sh=1080
rem set display mode Sw,Sh,32
load dll "user32.dll",1
Sw=call dll(1,"GetSystemMetrics",0)
Sh=call dll(1,"GetSystemMetrics",1)
delete dll 1
set display mode Sw,Sh,32,1
backdrop on
color backdrop rgb(10,100,100)
autocam off
set global collision off
objx#=750:objz#=750:targetx#=2250:targetz#=1750
objangle#=0.0:speed#=0.0:height#=0.0
cx#=0.0:cy#=0.0:cz#=0.0:ca#=0.0:camght=0:cax#=0
camrot=0:camdist=0
gosub Setupland1
gosub make_object
gosub make_target_object
gosub ambient
gosub resetcam2
_____DO_LOOP_____:
do
if inkey$()="s" then start=1:speed#=3.0
if inkey$()="a" then start=0:speed#=0.0
if inkey$()="r" then gosub reset
gosub printdata
gosub camera_controls
gosub update_camera
gosub check_direction
gosub active_object_move
gosub target_distance
gosub move_target
SYNC
loop
active_object_move:
if tdist#<5 then return
objx#=newxvalue(objx#,objangle#,speed#)
objz#=newzvalue(objz#,objangle#,speed#)
height#=get ground height(1,objx#,objz#)
position object 10,objx#,height#,objz#
yrotate object 10,objangle#
return
check_direction:
if tdist#<5 then return
distx#=targetx#-objx#
distz#=targetz#-objz#
dirangle#=atanfull(distx#,distz#)
if start=1
objangle#=curveangle(dirangle#,objangle#,20)
endif
return
target_distance:
tdist#=sqrt((targetx#-objx#)*(targetx#-objx#)+(targetz#-objz#)*(targetx#-objx#))
if tdist#<5 then speed#=0.0
return
move_target:
if mouseclick()=1
mymousex=mousemovex():mymousey=mousemovey()
targetx#=targetx#+mymousex:targetz#=targetz#+mymousey
position object 11,targetx#,height#,targetz#
endif
mousemovex()=0:mousemovey()=0
return
reset:
objx#=750:objz#=750:objangle#=0.0:speed#=0.0:height#=0.0:start=0:dirangle#=0
position object 10,objx#,height#,objz#
targetx#=2250:targetz#=1750
position object 11,targetx#,height#,targetz#
camfollow=0:gosub resetcam2
return
rem -------------ROUTINES--------------------
____SET_SCENERY___:
Setupland1:
rem ground textures
rem create texture
cls rgb(0,100,20)
inkcolor#=rgb(255,255,255)
line 0,0,0,250
line 1,1,1,250
line 2,2,2,250
line 0,0,250,0
line 1,1,250,1
line 2,2,250,2
line 0,0,250,250
line 0,250,250,0
rem next n
get image 2,0,0,250,250
rem Make landscape
landsize=5000:grid=10:mtxrandomize=1
make matrix 1,landsize,landsize,grid,grid
set matrix 1,1,0,0,1,1,1,1
prepare matrix texture 1,2,1,1
randomize matrix 1,mtxrandomize
rem ***********
rem get ground done
update matrix 1
return
______CAMERA_ROUTINES____:
rem -------CAMERA--------
camera_controls:
mymousez=mousemovez()
if mymousez>0 then camdist=camdist+10
if mymousez<0 then camdist=camdist-10
if inkey$()="c" then camrot=camrot+1.0
if inkey$()="x" then camrot = 180:camdist=500:camfollow=1
if inkey$()="v" then camhgt=camhgt+20
if inkey$()="b" then camhgt=camhgt-20
if inkey$()="z" then gosub Resetcam:camfollow=1
if inkey$()="<" then gosub Resetcam2:camfollow=0
return
rem camera update
update_camera:
cx#=newxvalue(objx#,ca#,camdist)
cz#=newzvalue(objz#,ca#,camdist)
cy#=height#+camhgt
rem ca#=curveangle(objangle#,ca#,20)
if camfollow=1 then ca#=objangle#
if camfollow=0 then ca#=0
position camera cx#,cy#,cz#
yrotate camera ca#+camrot
xrotate camera cax#
return
rem camera resets
Resetcam:
set camera range 1,20000
camdist=-400
camhgt=200
camrot=0
cax#=10.0
xrotate camera cax#
return
Resetcam2:
camdist=10:camhgt=2000:camrot=0:cax#=90:set camera range 100,20000
return
_____PRINT_ON__SCREEN___:
printdata:
set cursor 0,0
print "Polys=",statistic(1)
print "FPS=",screen fps()
print "-----OBJECT DATA-----"
print " objx#= ",objx#
print " objz#= ",objz#
print " height#= ",height#
print " objangle#= ",objangle#
print " speed#= ",speed#
print "-----TARGET DATA-----"
print " target x= ",targetx#
print " target z= ",targetz#
print " target distance= ",tdist#
print " target direction angle(dirangle#)= ",dirangle#
print "--------ACTIONS-----------"
print " s = start object move"
print " a = stop object"
print " r = restart"
print " LMouse to move target"
print " z,x,c,v,b, = various cameras"
print " < = reset top camera"
return
____MAKE_OBJECTS____:
make_object:
objnum=10
make object cone objnum,50
set object objnum,1,1,0,1,1,1,1
scale object objnum,100,200,100
xrotate object objnum,90
fix object pivot objnum
position object objnum,objx#,height#,objz#
yrotate object objnum,objangle#
return
make_target_object:
objnum=11
make object cube objnum,50
set object objnum,1,1,0,1,1,1,1
position object objnum,targetx#,height#,targetz#
return
rem ------------------ambient----------------
_______AMBIENT_______:
ambient:
set ambient light 70
set directional light 0,0.1,0.2,0.25
position light 0,0.0,2000.0,0.0
point light 0,4000,0,4000
fog on
fog color rgb(150,150,200)
fog distance 50000
return
end