One of the main problems I had so far was how to jump realistically using the dark physics character controller. I found the code here [href]null[/href]
http://forum.thegamecreators.com/?m=forum_view&t=87787&b=30 to be very helpful – though it made the character fly more than jump.
Here is an example showing how I have solved the problem. You will need the dark physics plug-in to run this. no media used
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
color object 13,RGB(255,0,0)
`make rigid bodies
for temp=10 to 13
phy make rigid body static box temp
next temp
`make charechter
make object box 3,3,10,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, 1.5, 45.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
`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
I have added the executable for download also – you will need the physx drivers to run that.