I want to be able to move automatically to new starting position and this is the code I have but it dont work properly. Sometimes it moves off the map and sometimes it works I know the placeplayer routine works correctly.
rem the map is a random matrix 1000 * 1000
newx#=x#:newz#=z#
gosub placePlayer:show object player1
rem place player creates x# y# and z# at new coords
rem This is where I want the camera and player to end up
ang#=object angle y(player1)
repeat
if newx#>x# then newx#=newxvalue(newx#,ang#,-1)
if newx#<x# then newx#=newxvalue(newx#,ang#,1)
if newz#>z# then newz#=newxvalue(newz#,ang#,-1)
if newz#<z# then newz#=newxvalue(newz#,ang#,1)
y#=get ground height(mymatrix,newx#,newz#)
position object player1,newx#,y#,newz#
position camera newx#,y#,newz#
SET CAMERA TO FOLLOW newx#,newy#,newz#,ang#+(180),cdist,chght,csmth,1
sync
until x#<(newx#+1) and x#>(newx#-1) and z#<(newz#+1) and z#>(newz#-1)
fubar