How do I get the default camera to always look in the direction the vehicle or object is moving.
I'm pretty new at this, so I need a quick answer.
The code is below, but you can download the file below the code.
Set Display Mode 1024,768,32
Text 0,0,"Vehicle Test"
Text 0,15,"version 0.1"
Text 0,30,"This is for demostration purposes only"
Wait Key
`Parameters of car
type carType
carNum as integer
objNum as integer
carState as integer
angle as float
cd as float
ft as float
fd as float
engine as float
engineStep as float
speed as float
curSpeed as float
prevSpeed as float
acceleration as float
curAcceleration as float
turning as float
count as integer
curAngle as float
transmission as integer
endtype
sync on
`Ñîçäà åì ìà òðèöó
make matrix 1,3000,3000,20,20
`Çà ãðóæà åì ìà øèÃó
global car as carType
car.carNum=getFreeObject()
car.cd=0.2
car.engineStep=0.01
car.transmission=1
load object "car.x",car.carNum
show object car.carNum
set ambient light 50
position object car.carNum,1500,0,1500
`Making Helper objects
car.objNum=getFreeObject()
make object plain car.objNum,5,5
hide object car.objNum
car.carState=getFreeObject()
make object plain car.carState,5,5
hide object car.carState
``MAIN LOOP
``Engine sound
do
``Controls
if rightkey() then car.angle=wrapvalue(car.angle+car.turning):car.engine=car.speed-car.engineStep/2
if leftkey() then car.angle=wrapvalue(car.angle-car.turning):car.engine=car.speed-car.engineStep/2
if upkey() then car.engine=car.speed+(car.engineStep)
if downkey() then car.engine=car.engine-(0.007):`car.speed=car.speed-0.01
if scancode()=0 then car.engine=car.speed-car.engineStep/150
`Calculating velocity
car.prevSpeed=car.speed
car.ft=car.engine
car.fd=-car.cd*car.speed*car.speed
car.speed=car.ft+car.fd
if car.speed<0.0 then car.speed=0.0
`Calculating acceleration
car.acceleration=(car.Speed-car.prevSpeed)*100
car.curAcceleration=curvevalue(car.acceleration,car.curAcceleration,10)
`Transmissions
if car.speed>=0 and car.speed<0.20 then car.cd=0.05:car.engineStep=0.01:car.transmission=1
if car.speed>=0.2 and car.speed<0.8 then car.cd=0.00316:car.engineStep=0.005:car.transmission=2
if car.speed>=0.8 and car.speed<1.2 then car.cd=0.0006:car.engineStep=0.003:car.transmission=3
if car.speed>=1.2 then car.cd=0.00009:car.engineStep=0.001:car.transmission=4
``Calculating rotating speed as speed function
car.turning=car.speed*1.0
``Updating car orientation and position
car.curAngle=curveangle(car.angle,car.curAngle,40)
yrotate object car.carNum,car.curAngle
move object car.carNum,car.Speed
set cursor 0,0
print screen fps()
print car.speed*100
print car.curAcceleration
print car.transmission
position object car.objNum,object position x(car.carNum),object position y(car.carNum),object position z(car.carNum)
set object to object orientation car.objNum,car.carNum
move object car.objNum,10
position object car.objNum,object position x(car.objNum),object position y(car.objNum)+car.curAcceleration,object position z(car.objNum)
set object to object orientation car.carState,car.carNum
point object car.carNum,object position x(car.objNum),object position y(car.objNum),object position z(car.objNum)
sync
set object to object orientation car.carNum,car.carState
position camera object position x(car.carNum)+0,object position y(car.carNum)+00,object position z(car.carNum)+30
if inkey$()="1" then position camera object position x(car.carNum)+30,object position y(car.carNum)+50,object position z(car.carNum)+50
if inkey$()="2" then position camera object position x(car.carNum)+0,object position y(car.carNum)+30,object position z(car.carNum)+80
move camera 5
loop
`END MAIN LOOP
`returns the number on which object can be loaded
function getFreeObject
repeat:tmp=rnd(40000):until object exist(tmp)<>1
endfunction tmp
http://www.freewebs.com/antalis/files/beta1.rar