I was in the process of trying to make a basic FPS engine in DBPro and i wanted it to use proper physics, i gave newton a try but its more complex then i thought and i don't have much time to try and learn it, so i chose ODE, with help from the codebase and code snippets i got a basic engine set up but my box doesn't react properly, i used the mass and friction technique from a recent code snippet that works fine but it doesn't seem to work on mine, the box just slides until it falls off into oblivion, any ideas?
sync on
hide mouse
autocam off
playermass#=(80)^(1.0/3.0)
boxmass#=(90*300*30)^(1.0/3.0)
floormass#=(3000*10*3000)^(1.0/3.0)
rem preparing ode physics engine
ode start
ode set world gravity 0.0,-9.79,0.0
ode set world step 0.07
ode set world erp (0.2)*2.5
ode set world cfm (10^-5)*2.5
rem make player movement sphere
make object sphere 4,80
position object 4,0,100,0
hide object 4
ODE CREATE DYNAMIC SPHERE 4
ode set contact fdir1 4,5
ODE SETSURFACE MODE CONTACT APPROX1 4,5
ODE SET BODY MASS 4,playermass#/30.0
make object box 2,3000,10,3000
color object 2,RGB(128,128,128)
ode create static box 2
ode set contact fdir1 2,1+rnd(10)
ode set body mass 2,floormass#/30.0
`test objects
make object box 10,90,300,30
color object 10,RGB(244,128,0)
position object 10,300,2,30
ode create dynamic box 10
ode set contact fdir1 4,1+rnd(5)
ode set body mass 10,boxmass#/30
`raycast sphere
make object sphere 7,10
do
if keystate(17)=1
speed#=speed#+0.3
ODE SET ANGULAR VELOCITY 4,SIN(camera angle y()+90)*speed#*2,0,COS(camera angle y()+90)*speed#*2
endif
if keystate(31)=1
speed#=speed#+0.3
ODE SET ANGULAR VELOCITY 4, (SIN(camera angle y()+90)*speed#)*-2,0,(COS(camera angle y()+90)*speed#)*-2
endif
if keystate(30)=1
speed#=speed#+0.3
ODE SET ANGULAR VELOCITY 4, (SIN(camera angle y()+360)*speed#)*2,0,(COS(camera angle y()+360)*speed#)*2
endif
if keystate(32)=1
speed#=speed#+0.3
ODE SET ANGULAR VELOCITY 4, (SIN(camera angle y()+180)*speed#)*2,0,(COS(camera angle y()+180)*speed#)*2
endif
`player walk speed
if speed#>0.2then speed#=0.2
if speed#<0 then speed#=0
speed#=speed#-0.2
`position camera
position camera object position x(4),object position y(4)+50,object position z(4)
`first person camera handling
oldcamy#=camy#
oldcamx#=camx#
camy#= wrapvalue(camy#+mousemoveY()*0.2)
camx#= wrapvalue(camx#+mousemoveX()*0.2)
rem stop mouse looking too far down
if camy#>70 and camy#<180 then camy#=70
if camy#<300 and camy#>200 then camy#=299
rem cam rotation with interp'. NOTICE X Y inversion
yrotate camera curveangle(camx#,oldcamx#,25)
xrotate camera curveangle(camy#,oldcamy#,25)
`keep player upright
ode set body rotation 4,0,camera angle y(),0
ode update
sync
loop
ode end
end