Try this:
do
`Store object angle y
ay# = object angle y(1)
`Move player forward
if upkey()=1
xtest# = Newxvalue(x#,ay#,20)
ztest# = Newzvalue(z#,ay#,20)
if xtest#>0 and xtest#<500 and ztest#>0 and ztest#<500
move object 1,10
endif
endif
`Turn player left or right
if leftkey()=1 then yrotate object 1,wrapvalue(ay#-3)
if rightkey()=1 then yrotate object 1, wrapvalue(ay#+3)
`move player backwards
if downkey()=1
xtest# = Newxvalue(x#,ay#,20)
ztest# = Newzvalue(z#,ay#,20)
if xtest#>0 and xtest#<500 and ztest#>0 and ztest#<500
move object 1,-10
endif
endif
`Store X,Y,Z of object position
x# = object position x(1)
y# = object position y(1)
z# = object position z(1)
gh#=get ground height(1,x#,z#)
position object 1,x#,gh#,z#
`Store camera position in CZ,CX coordinates
cz# = newzvalue(z#,ay#-180,200)
cx# = newxvalue(x#,ay#+180,200)
`Reposition camera as player moves
position camera cx#,150,cz#
`Point camera down in the direction of player
point camera x#,100,z#
`Holds current camera X,Y,Z angle position to the matrix
cx#=camera angle x()
cy#=camera angle y()
cz#=camera angle z()
sync
loop
Get rid of everything you have that is in your post between:
do
sync
loop
and put what I have.
You have to track all x,y,z coordinates of the object so you know where the object is so the camera can follow it. You also track everything for the camera. So if you move forward, backwards, turn left or right the camera will follow.
I believe I have it commented well enough so you can understand what the code is doing. You may have to change the variable names or the coordinates to get it just the way you want it to look, but this is straight out out my program. Hope this helps.
Any questions just ask.
3.0 Ghtz/1GB DDR400 Ram/Ati 9550 256MB AGP Graphics/100GB Maxtor Sata Drive/Dark Basic Pro 6.5
Know one cares how much you know until they know how much you care.