Thanks guys thanks latch and steve paul thomas but I am still getting problems I get it to run but can get everything to separate so I can get the player to get in and out of the aircraft or the hovercraft, also when I do testbox.x just means for you to made or get a box model and use them for the player, aircraft and hovercraft models, also had to change the player object from player to object1 as it won't read the player label
REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM Solar Dominion in and Out of Vehicle Test
REM Author :Ian George aka Vampyre
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
autocam off
hide mouse
sync rate 60
sync on
REM Variables
invehicle=0
inaircraft=0
player = 1
Rem Backdrop On
Backdrop on
REM FOG
Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
REM Make Matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem Make drone to mark a back position
make object sphere 3,10
hide object 3
REM player object
load object "testbox.X", 1
REM Get Ground Height
Y# = Get ground height(1,X#,Z#)
Position object player, X#+1,Y#+0.30,Z#
REM Aircraft Object
load object "testbox.X", 4
REM Object Collisions
Set object collision to spheres 4
set object collision on 4
rem Rotate and fix data so character faces right way
xrotate object 4,0
yrotate object 4,180
zrotate object 4,0
fix object pivot 4
Position object 4, X#+1,Y#+0.70,Z#
rem Hovercraft Object
load object "testbox.x",2
rem Rotate and fix data so character faces right way
xrotate object 2,0
yrotate object 2,180
zrotate object 2,0
fix object pivot 2
REM Get Ground Height
Y# = Get ground height(1,X#,Z#)
Position object 2, X#+1,Y#+0.50,Z#
rem scaling to 10% (YOU WILL NEED TO ADJUST THIS)
scale object 2,100,100,100
cammode = 0
REM MAIN PROGRAM LOOP
do
`gosub _Input
gosub _UpdateHovercraft
`gosub _UpdateObject1
REM THIS SUB DOES NOT HAVE A LABEL YET!
gosub _UpdateAircraft
sync
loop
REM Player pilot controls
_UpdatePlayer:
if invehicle=0
ncxa#=camera angle x()
ncya#=camera angle y()
nibopx#=object position x(1)
nibopy#=object position y(1)
nibopz#=object position z(1)
position camera object position x(1),object position y(1),object position z(1)
rotate camera object angle x(1),object angle y(1),object angle z(1)
wvtx=object angle x(1)
wvty=object angle y(1)
wvtz=object angle z(1)
wcax=wrapvalue(wvtx)
wcay=wrapvalue(wvty)
wcaz=wrapvalue(wvtz)
rotate camera wrapvalue(cxa#),cya#,0
rotate object self,0,camera angle y(),0
position camera object position x(1),object position y(1),object position z(1)
REM YOU HAD THIS TO ROTATE self, DID YOU MEAN PLAYER?
rotate object player,0,camera angle y(),0
position camera object position x(1),object position y(1),object position z(1)
endif
if keystate(17)=1 or upkey()=1
x#=newxvalue(x#,cya#,16.0) : z#=newzvalue(z#,cya#,16.0)
endif
if keystate(31)=1 or downkey()=1
x#=newxvalue(x#,cya#,-16.0) : z#=newzvalue(z#,cya#,-16.0)
endif
if keystate(30)=1 or leftkey()=1
x#=newxvalue(x#,wrapvalue(cya#-90.0),20.0)
z#=newzvalue(z#,wrapvalue(cya#-90.0),20.0)
endif
if keystate(32)=1 or rightkey()=1
x#=newxvalue(x#,wrapvalue(cya#+90.0),20.0)
z#=newzvalue(z#,wrapvalue(cya#+90.0),20.0)
endif
if jumpb=1
height#=height#-.7
endif
REM RETURN TO MAIN PROGRAM
return
_UpdateHovercraft:
rem hovercraft controls
if invehicle=1
mmy=mousemovey()
mmx=mousemovex()
endif
if mmy>0 then pitch object up 2,0.002
if mmy<0 then pitch object down 2,0.002
if mmx<0 then turn object left 2,5
if mmx>0 then turn object right 2,5
if upkey()=1 then move object 2,40
if downkey()=1 then move object 2,-40
if scancode()=17 then move object 2,40
if scancode()=31 then move object 2,-40
if joystick up()=1 then pitch object up 2,0.0002
if joystick down()=1 then pitch object down 2,0.0002
if joystick left()=1 then turn object left 2,5
if joystick right()=1 then turn object right 2,5
if joystick slider a()=0 then move object 2,40
if joystick slider a()=65535 then move object 2,-40
REM Straffe Left
if joystick twist z()=-1000
turn object left 2,90 : move object 2,20 : turn object right 2,90
endif
REM Straffe Right
if joystick twist z()=1000
turn object right 2,90 : move object 2,20 : turn object left 2,90
endif
REM Straffe Left
if scancode()=30
turn object left 2,90 : move object 2,20 : turn object right 2,90
endif
REM Straffe Right
if scancode()=32
turn object right 2,90 : move object 2,20 : turn object left 2,90
endif
REM Straffe Left
if leftkey()=1
turn object left 2,90 : move object 2,20 : turn object right 2,90
endif
REM Straffe Right
if rightkey()=1
turn object right 2,90 : move object 2,20 : turn object left 2,90
endif
REM Hovercaft Jump
if jumpb=1
height#=height#-.7
endif
if joystick fire x(4) or spacekey()=1 and ajump=1
jumpb=1
height#=20
endif
if height#<-13 then height#=-13
rem MAKE IF...ELSE LOOK LIKE THIS
if object position y(2)>100
ajump=0
else
ajump=1
endif
position object 2,object position x(2),object position y(2)+height#,object position z(2)
if object position y(2)<100
jumpb=0
height#=0
endif
rem HAT control
jhat=joystick hat angle(0)
print westminster
text 10,10,"HAT signal: "+str$(jhat)
text 10,20,"Joystick: "+str$(jx)+"/"+str$(jy)
text 10,30,"Slider: "+str$(joystick slider a())
text 10,40,"FPS: "+str$(screen fps())
text 320,400,"Speed: "+str$(intspeed)+"MPH"
_UpdateAircraft:
rem air/spacecraft movement controls
if inaircraft=1
mmy=mousemovey()
mmx=mousemovex()
endif
if mmy>0 then pitch object up 4,5
if mmy<0 then pitch object down 4,5
if mmx<0 then turn object left 4,5
if mmx>0 then turn object right 4,5
if upkey()=1 then move object 4,40
if downkey()=1 then move object 4,-40
if scancode()=17 then move object 4,40
if scancode()=31 then move object 4,-40
if inkey$() = "q" then roll object left 4,5
if inkey$() = "e" then roll object right 4,5
if scancode()=211 then roll object left 4,5
if scancode()=209 then roll object right 4,5
if joystick up()=1 then pitch object up 4,5
if joystick down()=1 then pitch object down 4,5
if joystick left()=1 then turn object left 4,5
if joystick right()=1 then turn object right 4,5
if joystick twist z()=1000 then roll object left 4,5
if joystick twist z()=-1000 then roll object right 4,5
if joystick slider a()=0 then move object 4,40
if joystick slider a()=65535 then move object 4,-40
REM Straffe Left
if joystick fire x(4)=1
turn object left 4,90 : move object 4,20 : turn object right 4,90
endif
REM Straffe Right
if joystick fire x(5)=1
turn object right 4,90 : move object 4,20 : turn object left 4,90
endif
REM Straffe Left
if scancode()=30
turn object left 4,90 : move object 4,20 : turn object right 4,90
endif
REM Straffe Right
if scancode()=32
turn object right 4,90 : move object 4,20 : turn object left 4,90
endif
REM Straffe Left
if leftkey()=1
turn object left 4,90 : move object 4,20 : turn object right 4,90
endif
REM Straffe Right
if rightkey()=1
turn object right 4,90 : move object 4,20 : turn object left 4,90
endif
rem VTOL take off and landing
if joystick fire x(6)
position object 4,object position x(4),object position y(4)+height,object position z(4)
height=10
endif
if controlkey()=1
position object 4,object position x(4),object position y(4)+height,object position z(4)
height=10
endif
if joystick fire x(7)
position object 4,object position x(4),object position y(4)-10,object position z(4)
height=height-1
endif
if spacekey()=1
position object 4,object position x(4),object position y(4)-10,object position z(4)
height=height-1
endif
rem HAT control
jhat=joystick hat angle(0)
print westminster
text 10,10,"HAT signal: "+str$(jhat)
text 10,20,"Joystick: "+str$(jx)+"/"+str$(jy)
text 10,30,"Slider: "+str$(joystick slider a())
text 10,40,"FPS: "+str$(screen fps())
intspeed=int(speed#*150)
intspeed=int(speed#-150)
if timer()>t
rem then we add another half second to t
t=timer()+500
rem so the IF part of this bit will only be true when timer() is equal to t
endif
rem RETURN TO MAIN PROGRAM
return
`_Input:
` if spacekey()=1
` hide object 1
` invehicle=1
` else
` if spacekey()=1
` show object 1
` position object 1,object position x(HOVERCRAFT_TANK)-20,object position y(hovercraft_tank), object position z(hovercraft_tank)
` invehicle=0
` endif
rem HAT control
jhat=joystick hat angle(0)
print westminster
text 10,10,"HAT signal: "+str$(jhat)
text 10,20,"Joystick: "+str$(jx)+"/"+str$(jy)
text 10,30,"Slider: "+str$(joystick slider a())
text 10,40,"FPS: "+str$(screen fps())
text 320,400,"Speed: "+str$(intspeed)+"MPH"
rem Set the hat look flags to nothing
lookUp = 0: lookLeft = 0: lookRight = 0: lookBack = 0
if jhat = 0 then lookUp = 1
if jhat=9000 or jhat=4500 or jhat=13500 then lookRight = 1
if jhat=31500 or jhat=27000 or jhat=22500 then lookLeft = 1
if jhat = 18000 then lookBack = 1
rem Third person
If InKey$() = "1" Then cammode = 1
rem First person
If InKey$() = "2" Then cammode = 0
If cammode = 0
rem Place camera and set orientation to object for FPS
position camera object position x(2),object position y(2),object position z(2)
set camera to object orientation 2
if lookRight = 1 then turn camera right 90.0
if lookLeft = 1 then turn camera left 90.0
if lookUp = 1 then pitch camera up 45.0
if lookBack = 1 then turn camera right 180.0
else
rem Place as over head for 3rd person
move object 1,-150
position object 3,object position x(1),object position y(1),object position z(1)
move object 1,150
rem Place camera and set orientation to object
position camera object position x(3),object position y(3),object position z(3)
set camera to object orientation 1
endif
REM RETURN TO MAIN PROGRAM
return