Hi, I believe I have solved your problem. Is this what you were trying to achieve?
Sw=1024:Sh=768
set display mode Sw,Sh,32,1
set window off
sync on : sync rate 0
hide mouse
`Set Text
set text font "Verdana"
set text size 15
set text to bold
ink rgb(200,200,0),0
Make Matrix 1, 500,500,100,100
make object cube 1,1
Color object 1, RGB(255,0,0)
Position object 1, 255,0 ,255
speed# = 0.4
Do
`rotatse the object only if of the key q isn't pressed
If KEYSTATE(16)=0
MMx = MouseMoveX()
Y# = WrapValue(Object Angle Y(1)+MMx): Yrotate Object 1,Y#
endif
`controling the object
if upkey()=1 or KEYSTATE(17)=1
Move object 1, speed#
endif
if downkey()=1 or KEYSTATE(31)=1
move Object 1, -(speed#)
endif
if rightkey()=1 or KEYSTATE(32)=1
Move object right 1, speed#
endif
if leftkey()=1 or KEYSTATE(30)=1
Move object left 1, speed#
endif
if KEYSTATE(57)=1
position object 1, object position x(1) , object position y(1), object position z(1)
endif
if upkey()=1 AND downkey()=1 or KEYSTATE(17)=1 AND KEYSTATE(31)=1 or leftkey()=1 AND rightkey()=1 or KEYSTATE(30)=1 AND KEYSTATE(32)=1
Move object 1, 0
endif
`Camera Position befor viewing arround
opx1# = object position x(1)
opy1# = object position y(1)
opz1# = object position z(1)
`Free Cammoving
if KEYSTATE(16)=1
position camera 0, opx1#, opy1#+ReqCamHeight#-3.0, opz1#
if mouseclick()=0
xrotate camera camera angle x()-mousemovey()*0.25
yrotate camera camera angle y()+mousemovex()*0.25
if camera angle x()>80 then xrotate camera 80
if camera angle x()<-60 then xrotate camera -60
endif
if mouseclick()>0 then CamDis#=CamDis#-mousemovey()*0.25
CamDis#=CamDis#+mousemovez()*0.25
if CamDis#>-15 then CamDis#= -15
if CamDis#<-300 then CamDis#=-300
move camera CamDis#
if camera position y()<-60 then position camera camera position x(),-60,camera position z()
mousemovex()=0
mousemovey()=0
endif
`Camera Position after viewing arround
opx# = object position x(1)
opy# = object position y(1)
opz# = object position z(1)
`get the groundheight of the matrix
ObjHeight# = Get Ground Height(1,Opx#,Opz#)
Position Object 1,Opx#,ObjHeight#+1.0,Opz#
Camheight# = ObjHeight#+ReqCamHeight#
`Set Camera to follow if q isn't pressed
if KEYSTATE(16)=0
TrackAngle = 0:
ReqCamHeight# = 7.0
Camsmooth = 10
ColFlag = 0
Camdis# = 15
`Set Camera tp Follow
set camera to object orientation 1 // Hodgey's addition
Set Camera To Follow Opx#,ObjHeight#,Opz#,WrapValue(Object Angle Y(1)+TrackAngle),Camdis#,Camheight#,Camsmooth,ColFlag
endif
`Text
center text sw/2,50,"FPS "+str$(screen fps())
Sync
Loop
The difference is I added the 'Set camera to object orientation' command. I have commented where I have added it. Hope this is the solution
A clever person solves a problem, a wise person avoids it - Albert Einstein