Oh how the past comes back to haunt you......
The code you are referring to was part of my N-vidia 2006 compo entry and I had thought someone had come up with a better solution since then. I have tried the code on slopes and you are right. I never came across this problem because there were not really any slopes in that game.
The problem seems to be because the code checks if the jump has finished before allowing you to jump again. It does this by seeing if your Y position has changed. Since on a slope your Y position changes, you then can’t jump.
Only way I can see to solve the problem is to check for collision.
REM Project: PhyJump
REM Created: 15/12/2006 11:20:51
REM
REM ***** Main Source File *****
REM
`Use W.S.A.D or Curser keys + mouse to move
`Use Space To Jump
`pretty standand initialisation routine
sync on
phy start
` i use a scale of one DB point= one centimetre - the standard is one Metre
`so gravity has to be scaled by 100
phy set gravity 0.0,-98, 0.0.
autocam off
hide mouse
set ambient light 50
sync rate 60
`variables
sw=screen width() : sh=screen height()
`charicter position variables
gx#=0 : gy#=10: gz#=0
`how long charecter hill jump for and the speed at which they jump
jumpspeed=-250 : jumptime=31
`camera
camheight=10
camdist=-20
`Make a simple scene
make object box 10,1000,5,1000
position object 10,0,0,0
color object 10,RGB(128,128,0)
make object box 11,50,5,50
position object 11,50,50,50
color object 11,RGB(0,255,0)
make object box 12,50,5,50
position object 12,25,25,25
color object 12,RGB(128,128,255)
make object box 13,50,5,50
position object 13,25,75,25
rotate object 13,0,0,-45
color object 13,RGB(255,0,0)
make object box 14,500,5,50
position object 14,125,50,-125
rotate object 14,0,0,15
color object 14,RGB(0,255,0)
make object box 15,500,5,50
position object 15,125,30,-250
rotate object 15,0,0,45
color object 15,RGB(0,0,255)
`make rigid bodies
for temp=10 to 15
phy make rigid body static box temp
next temp
`make charechter
make object box 3,3,15,3
color object 3,RGB(255,0,255)
`phy make capsule character controller ID, x#, y#, z#, radius#, height#, up, step#, slope limit#
phy make capsule character controller 3, gx#,gy#,gz#, 1.5,10, 1, 2, 60.0
`main loop
do
`this bit just checks mouse position and keeps it in the screen - helps if using a window
mx=mousex()
my=mousey()
if mx>sw-2 then mx=mx-sw
if mx<1 then mx=sw-mx
if my>sh-2 then my=my-sh
if my<1 then my=sy-my
position mouse mx,my
`make charachter fall
oldjgy#=object position y(3)
phy set character controller displacement 3, 98, 0
phy move character controller 3, 0.1
phy move character controller 3, -0.1
`check position and rotate charachter with mouse
move=0
grx#=object angle x(3)
gry#=object angle y(3)
grz#=object angle z(3)
gry#=wrapvalue(gry#+ (mousemovex()/2))
yrotate object 3,gry#
oldgry#=gry#
`this bit moves charachter with wsad or cursor keys
`left
if keystate(30)=1 or keystate(203)=1
phy set character controller displacement 3, 0, 0
yrotate object 3,wrapvalue(gry#-90)
phy move character controller 3, 50.0
yrotate object 3,oldgry#
move=1
endif
`right
if keystate(32)=1 or keystate(205)=1
phy set character controller displacement 3, 0, 0
yrotate object 3,wrapvalue(gry#+90)
phy move character controller 3, 50.0
yrotate object 3,oldgry#
move=1
endif
`forward
if keystate(17)=1 or keystate(200)=1
phy set character controller displacement 3, 0, 0
phy move character controller 3, 50.0
move=1
endif
`back
if keystate(31)=1 or keystate(208)=1
phy set character controller displacement 3, 0, 0
phy move character controller 3, -40.0
move=1
endif
`this is the bit that caused me much problems
`jumping
`tags are
` jump=0 : no jump
`jump<0 : Falling
`jump>0 : rising
`check we want to jump
if spacekey()=1 and jump=0 then startgy#=object position y(3):jump=1 :oldgy#=0
if jump>0
`this checks to see if characher has a restricted jump ( platform above the head )
if object position y(3)=oldgy# then jump=jumptime-1
oldgy#=object position y(3)
`move charachter up
phy set character controller displacement 3, 0,jumpspeed
`displacement only seems to work when characher is moving - so move it a wee bit then back a wee bit
phy move character controller 3, 0.1
phy move character controller 3, -0.1
jump=jump+1 `incrament timer
if jump=jumptime then jump=-1
endif
`this is a check that the jump has finished before you can start a new jump
if jump<0
jump=jump-1
if jump<(0-jumptime)
jgy#=object position y(3)
if jgy# = oldjgy# then jump=0
endif
endif
`check to see if you are touching the ground (to get collision i had to make the player bigger than controler capsule)
hit = object collision(3,0)
if hit>9
`check to see collision is not above player
jump=0
endif
`documentation states for smooth movement you should allways call this comand - even if not moving
if move=0 then phy move character controller 3, 0.0
`camera up and down
crx#=camera angle x()
crx#=wrapvalue(crx#+ (mousemovey()/2))
gx#=object position x(3)
gy#=object position y(3)
gz#=object position z(3)
position camera gx#,gy#+camheight,gz#
SET CAMERA TO OBJECT ORIENTATION 3
move camera camdist
if crx#> 45 and crx#<270 then crx#=45
if crx#<300 and crx#>269 then crx#=300
xrotate camera crx#
phy update
sync
loop
Also only way I can get proper collision (I tried both the PhysX collision and DBP collision) is to make the player bigger than the character control capsule.
This is not ideal as it would look as if your feet are in the ground. You could use an invisible actor positioned just below your player and use it for collision detection with the ground and it should look much better.
Hope this helps; I will try and find a better example of jumping for you or if someone else can think of a better solution please post.
Edit
After looking about I don’t see a better solution - though I would recommend using sparks collision DLL and an actor or ray cast to detect collision.