Well, the title explains it all, so if someone can run / analyze this code and give me any pointers, I'd greatly appreciate it. In the meantime I will be working on this issue as well.
sync on
sync rate 60
backdrop on
autocam off
color backdrop rgb(0,0,0)
phy start
`Loading
make object box 1,10,2,10
`phy make material 1, "ice"
`phy set material dynamic friction 1, 5
`phy build material 1
phy make rigid body static box 1`, 1
`make the player object
make object box 300,1,1,1
position object 300,0,2,0
phy make box character controller 300, 0,3, 0, 1,1,1, 1, 0.25 , 55.0
rotate camera 45,45,0
` our main loop
do
` rotate and position the camera based on the box controller
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
yrotate object 300, curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
` react to key presses and move the controller
key = 0
if keystate(42)=1
speed=1
else
speed=2
endif
if keystate(17)=1
key = 1
phy move character controller 300, speed
endif
if keystate(31)=1
key = 1
phy move character controller 300, -speed
endif
if keystate(30)=1
key = 1
rotate object 300,object angle x(300),object angle y(300)-90,object angle z(300)
phy move character controller 300, speed
rotate object 300,object angle x(300),object angle y(300)+90,object angle z(300)
endif
if keystate(32)=1
key = 1
rotate object 300,object angle x(300),object angle y(300)+90,object angle z(300)
phy move character controller 300, speed
rotate object 300,object angle x(300),object angle y(300)-90,object angle z(300)
endif
rx#=object position x(300)
ry#=object position y(300)
rz#=object position z(300)
value = phy ray cast all shapes( rx#, ry#, rz#, 0, -1, 0)
ground# = phy get ray cast distance( )
if ground#>1.1 and ground#<1.1001
jump=0
endif
if keystate(57)=1 and jump=0
jump=1
key=1
jumpval=150
endif
if jumpval>0
jumpval=jumpval-1
endif
rotate object 300,object angle x(300)-90,object angle y(300),object angle z(300)
phy move character controller 300,jumpval
rotate object 300,object angle x(300)+90,object angle y(300),object angle z(300)
if key = 0
phy move character controller 300, 0.0
endif
text 20,20,str$( screen fps())
text 20,35, str$(timer#)
text 20,45, str$(ground#)
` update the simulation and screen
position camera object position x(300)-3,object position y(300)+5,object position z(300)-3
phy update
sync
loop
Thanks!
BTW, I know that alot of people have trouble with getting jumping to work on the character controller and no real solution has ever been posted. Feel free to use this source code however you want. I was really excited when I finally got jumping to work properly last night and I'd love to share it with everyone.
Sometimes the only way over a wall is to pile up enough bodies to climb over - Dave W.