I used newzvalue and newxvalue, still it cuts out here is the code
EM *************************************************************
REM *************************************************************
REM *************************************************************
REM *************************************************************
REM *************************************************************
REM Solar Dominion In And Out Vehicles Test Levels
REM *************************************************************
REM *************************************************************
REM *************************************************************
REM *************************************************************
REM *************************************************************
autocam off
hide mouse
sync rate 50
sync on
`------
`ARRAYS
`------
`declare the MatEdit variables
Dim BigMatrix(600,600,1)
Dim StartLoc_X(1): Dim StartLoc_Z(1):Dim Info(2)
Dim TArrayX(1): Dim TArrayZ(1): Dim FKey(10,1)
Dim ColData(100): Dim ZoneData(100): Dim Tiles(500,500)
Dim OverTexture$(100): Dim OverName$(20): Dim ReplaceTex(100)
Dim MOffsetX(25): Dim MOffsetY(25)
Dim MWire(20): Dim MGhost(20): Dim Lock(20)
Dim MatX#(20): Dim MatY#(20): Dim MatZ#(20)
Dim MatWidth#(20): Dim MatHeight#(20)
Dim TilesX(20): Dim TilesZ(20)
Dim MatHi#(20): Dim MatLo#(20)
`player arrays
dim xSpeed#(4)
dim ySpeed#(4)
dim zSpeed#(4)
dim friction#(4)
dim movedist#(4)
`gravity
dim gravity#(0) : gravity#(0)=0.1
rem load image
load image "Blue White Line Galaxy.bmp",1
rem turn backdrop on
backdrop on
rem texture backdrop
texture backdrop 1
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
do
gosub_Input
gosub_UpdatePlayer
gosub_UpdateHovertank
sync
loop
rem Make drone to mark a back position
make object sphere 3,10
hide object 3
rem load player object
load object "idle.X",1
REM Mesh Player Object
make mesh from object 1,1
delete object 1
make object 1,1,1
rem scaling to 10% (YOU WILL NEED TO ADJUST THIS)
scale object 1,10,10,10
rem Rotate and fix data so character faces right way
xrotate object 1,0
yrotate object 1,180
zrotate object 1,0
fix object pivot 1
X# = object position X(1)
Z# = object position Z(1)
Y# = Get ground height(1,X#,Z#)
Position object 1,X#,20,Z#
AngleY# = 0.0
cammode = 0
rem Loop 3D object animation from 0 to 20 (idle)
`LOOP OBJECT 1,0,20 : SET OBJECT SPEED 1,40
rem in and out of vehicle vairables
inVehicle = 0
rem variables
player=1
hovertank=2
do
rem forward
_UpdatePlayer:
if invehicle=0
if upkey()=1 or keystate(17)
x# = newxvalue(x#,wrapvalue(AngleY#),10)
z# = newzvalue(z#,wrapvalue(AngleY#),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem backward
if downkey()=1 or keystate(31)
x# = newxvalue(x#,wrapvalue(AngleY#),-10)
z# = newzvalue(z#,wrapvalue(AngleY#),-10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem left
if leftkey()=1 or keystate(30)
x# = newxvalue(x#,wrapvalue(AngleY#-90),10)
z# = newzvalue(z#,wrapvalue(AngleY#-90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
rem right
if rightkey()=1 or keystate(32)
x# = newxvalue(x#,wrapvalue(AngleY#+90),10)
z# = newzvalue(z#,wrapvalue(AngleY#+90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif
xMouse=mousemovex()
yMouse=mousemovey()
AngleY#=wrapvalue(AngleY#+xMouse)
AngleX#=wrapvalue(AngleX#+yMouse)
Position object 1,x#,y#,z#
rotate object 1,AngleX#,AngleY#,0
return
rem If character action changes
IF stage<>oldstage
IF stage=0
SET OBJECT FRAME 1,0.0
LOOP OBJECT 1,0,20
SET OBJECT SPEED 1,10
ENDIF
IF stage=1
SET OBJECT FRAME 1,25
LOOP OBJECT 1,105,125
SET OBJECT SPEED 1,40
ENDIF
oldstage=stage
ENDIF
Return
rem load hovercraft object
load object "CDHTANK1.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#)
AngleY# = 0.0
` Hovercraft position
` rotate hovercraft to a random angle
ROTATE OBJECT 2,0,RND(360),0
` put it in a random position
POSITION OBJECT 2,(100+RND(300)),4,(100+RND(300))
rem scaling to 10% (YOU WILL NEED TO ADJUST THIS)
scale object 2,8000,8000,8000
rem movement
_UpdateHovertank:
if invehicle=1
if joystick left()=1 then AngleY# = wrapvalue( AngleY# - 1.5 )
if joystick right()=1 then AngleY# = wrapvalue( AngleY# + 1.5 )
if joystick up()=1 then pitch object up 2, 5.5
if joystick down()=1 then pitch object down 2,5.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()=64531 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 right
if joystick twist z()=1000 or rightkey()=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
Position object 2,x,150,z
yrotate object 2,AngleY#
rem left
if joystick twist z()=-1000 or leftkey()=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
rem Hovertank Jump
if controlkey()=1 or joystick fire x(7) and ajump=1
jumpb=1
height=350
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),150,object position z(2)
jump=0
height=0
endif
return
REM Make Mesh
make mesh from object 2,2
REM In and Out of Hovertank
hX# = OBJECT POSITION X(2)
hY# = OBJECT POSITION Y(2)
hZ# = OBJECT POSITION Z(2)
_Input:
rem check distance from vehicle
if (playerX#-hovertankX#)^2+(playerZ#-hovertankZ#)^2 <=160
rem If chartacter collides with vehicle
if object collision(1,2)=2
rem get into vehicle and make sure pilot is not detected anymore
glue object to limb 1,2,23
position object 1,0,0,0
position object 2, x, 150, z
invehicle=1
set object collision off 1
rem When spacebar is hit, exit the vehicle
if spacekey()=1
invehicle=0
unglue object 1
position object 2,x, 100,y
set object collision on 1
endif
endif
endif
If invehicle=1
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
endif
else
If InKey$() = "1" Then cammode = 1 : ` third person
If InKey$() = "2" Then cammode = 0 : ` first person
if invehicle=0
If cammode = 0
rem Place camera and set orientation to object for FPS
position camera object position x(1),object position y(1)+40,object position z(1)
set camera to object orientation 1
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
endif
endif
endif
sync
loop