I am making a FPS and I have found that I can look down and go through the matrix, and look up and walk in the air (without having to jump). I was wondering how could I go about restricting movement to not going through the matrix, and not going in the air unless you jump.
`Setup Client Options
SYNC ON:SYNC RATE 0:HIDE MOUSE
`Create Player
MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000):POSITION OBJECT 1,posx#,mat_ground#,posz#
`make a matrix
MAKE MATRIX 1,1000,1000,20,20
mat_ground#=GET GROUND HEIGHT(1,posx#,posz#)+10
`Add limb for intersection checks
MAKE OBJECT SPHERE 9999,10
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,500
HIDE LIMB 1,1
`Add a second limb for ground checks
ADD LIMB 1,2,1
OFFSET LIMB 1,2,0,-50,0
DELETE MESH 1
HIDE LIMB 1,2
`Define the main variables needed
JUMPING#=0`
JUMP$="Jumping"`
speed#=3.0` How fast player moves
posx#=250.0` Position player
posz#=250.0` Position player
eposx#=200.0` Enemy position
eposz#=249.0` Enemy Position
`Start main DO/LOOP
DO
`display the FPS
FPS#=SCREEN FPS()
TEXT 0,0,"FPS: "+STR$(FPS#)
`Camera Positioning
POSITION CAMERA OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)
`Movement Controls
IF KEYSTATE(17)=1 THEN MOVE OBJECT 1,.9
IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-.9
IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.6
IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.6
`get marix grid hieght for everything to be on
mground#=GET GROUND HEIGHT(1,posx#,posz#)+10
`Space key Controls
IF SPACEKEY()=1 AND JUMPING#=0 THEN JUMP#=1
`JUMP Variable Definition
IF JUMP#=1
GROUND#=OBJECT POSITION Y(1)
JUMP_SPEED#=1
JUMPING#=1
JUMP#=0
ENDIF
`Jumping
IF JUMPING#=1
DEC JUMP_SPEED#,.005
POSITION OBJECT 1,OBJECT POSITION X(1),OBJECT POSITION Y(1)+JUMP_SPEED#, OBJECT POSITION Z(1)
IF OBJECT POSITION Y(1)<=GROUND# THEN JUMPING#=0
ENDIF
`Mouse Camera Movement
CAMY#=CAMY#+MOUSEMOVEX()*.1
CAMX#=CAMX#+MOUSEMOVEY()*.1
IF CAMX#>90 AND CAMX#<135 THEN CAMX#=90
IF CAMX#>270 AND CAMX#<225 THEN CAMX#=90
YROTATE CAMERA CAMY#
XROTATE CAMERA CAMX#
YROTATE OBJECT 1,CAMY#
XROTATE OBJECT 1,CAMX#
SYNC
LOOP