I can seem to get my hovertank to go upwards when I press the controls I tried it both with my keyboard and and joystick , what is wrong and why does the "position Object command " keeping cutting out certain controls I can't get a proper VTOL plane because of this , can anyone help please?
Rem * Date : 05/10/04
REM ***************************************************************
REM ***************************************************************
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
REM Straffing Hovertank
REM Author :Ian George aka Vampyre
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
autocam off
hide mouse
sync rate 60
sync on
Make matrix 1,40000,40000,40,40
Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem Randomize the matrix
randomize matrix 1,125
update matrix 1
X#=5000
Z#=5000
rem Make drone to mark a back position
make object sphere 3,10
hide object 3
rem load hovercraft object
load object "Testbox.x", 2
rem Rotate and fix data so character faces right way
xrotate object 2,0
yrotate object 2,360
zrotate object 2,0
fix object pivot 2
X# = object position X(2)
Z# = object position Z(2)
Y# = Get ground height(1,X#,Z#)
Position object 2,x,150,y
AngleY# = 0.0
rem scaling to 10% (YOU WILL NEED TO ADJUST THIS)
scale object 2,3000,3000,3000
cammode = 0
do
rem movement
if joystick left()=1 then AngleY# = wrapvalue( AngleY# - 1.5 )
if joystick right()=1 then AngleY# = wrapvalue( AngleY# + 1.5 )
rem forwards
if joystick slider a()=0 or upkey()=1 or keystate(17)
x = newxvalue(x,wrapvalue(AngleY#),30)
z = newzvalue(z,wrapvalue(AngleY#),30)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem backwards
if joystick slider a()=65535 or downkey()=1 or keystate(31)
x = newxvalue(x,wrapvalue(AngleY#),-30)
z = newzvalue(z,wrapvalue(AngleY#),-30)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem left
if joystick twist z()=1000 or leftkey()=1 or keystate(32)
x = newxvalue(x,wrapvalue(AngleY#+90),30)
z = newzvalue(z,wrapvalue(AngleY#+90),30)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem right
if joystick twist z()=-1000 or rightkey()=1 or keystate(30)
x = newxvalue(x,wrapvalue(AngleY#-90),30)
z = newzvalue(z,wrapvalue(AngleY#-90),30)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
Position object 2,x,150,z
yrotate object 2,AngleY#
REM Jump Hover
if joystick fire x(8)=1 and ajump=1
jumpb=1
height=30
endif
if jumpb=1
height=height-1
position object 2,object position x(2),object position y(2)+height,object position z(2)
endif
if object position y(2)>100 then ajump=0 else ajump=1
if object position y(2)<100
position object 2,object position x(2),100,object position z(2)
jump=0
height=0
endif
rem HAT control
jhat=joystick hat angle(0)
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())
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
If InKey$() = "1" Then cammode = 1 : ` third person
If InKey$() = "2" Then cammode = 0 : ` first person
If cammode = 0
rem Place camera and set orientation to object for FPS
position camera object position x(2),object position y(2)+40,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 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,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 2
Endif
sync
loop
I put a testbox object in so anyone who whishs to help an use a box, name it "testbox" and load it into the program
Here is the VTOL flight code as well
REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM Flight VTOL
REM Author :Ian George aka Vampyre
REM ****************************************************************
REM ****************************************************************
autocam off
hide mouse
sync rate 60
sync on
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 Randomize the matrix
randomize matrix 1,125
update matrix 1
X#=5000
Z#=5000
rem Make drone to mark a back position
make object sphere 3,10
hide object 3
rem Aircraft Object
load object "AIRPL043.X", 2
airplane=1
airplaneX# = 150.0
airplaneY# = 3.0
airplaneZ# = 150.0
airplaneAngY# = 0.0
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
position object 2,x,100,z
rem scaling to 10% (YOU WILL NEED TO ADJUST THIS)
scale object 2,1000,1000,1000
cammode = 0
do
rem movement
if joystick up()=1 then pitch object up 2,5
if joystick down()=1 then pitch object down 2,5
if joystick left()=1 then turn object left 2,5
if joystick right()=1 then turn object right 2,5
if joystick twist z()=1000 then roll object left 2,5
if joystick twist z()=-1000 then roll object right 2,5
if joystick slider a()=0 then move object 2,40
REM VTOL Take off and Landing
if spacekey() or joystick fire x(6) then y#=y#+1
position object 2,x#,y#,z#
if controlkey()=1 or joystick fire x(5) then y#=y#-1
position object 2,x#,y#,z#
rem HAT control
jhat=joystick hat angle(0)
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())
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
If InKey$() = "1" Then cammode = 1 : ` third person
If InKey$() = "2" Then cammode = 0 : ` first person
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 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,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 2
Endif
sync
loop
In the VTOL code it keeps cutting out the other controls for me to fly around, and in the hovercraft code it doen't jump up and gradually move down and I can still move forwards and backwards it just cuts the jumping code out why is this? can I get help on this please?