This is a little flight simulator I was working on, I have nearly got the camera sorted; however the problem is that I need to use the "set camera to object orientation" command to allow the camera to fully follow the vehicle.
This means that it is very easy for the "plane" to go off screen if you turn, especially if you turn upwards or downwards. Is there a command that will let me control the camera if the plane is close to going off screen, so that the plane stays on screen?
Use the mouse to move, LMB to accelerate.
make object box 1,10,10,25
`load object "bridge.x",2
`scale object 2,25,25,25
make object sphere 2,1000
position object 2,0,0,2000
velocity=500
do
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
text 10,10,str$(velocity#)
move object 1,velocity#/100
if mouseclick()=1 and velocity#<750 then inc velocity#,0.33 else dec velocity#,velocity#/200
if velocity#<0.1 then velocity#=0
yrotate object 1,object angle y(1)+mousemovex()
xrotate object 1,object angle x(1)+mousemovey()
gosub setcamera
fastsync
loop
setcamera:
visibility=object visible(1)
text 10,50,str$(visibility)
set camera to follow x#,y#,z#,object angle y(1),85,10,10,0
set camera to object orientation 1
return