That way didn't work since it was making speed# 0 if it ever went less than zero, and since speed#=-.004 when I pushed left it wasn't letting me move left anymore.
However I fixed all of the problems I was having like this:
sync on:sync rate 50
make object box 1, 2, 2, 2
color object 1, rgb(rnd(100),rnd(100),rnd(100))
make object collision box 1, -1.5, -1.5, -1.5, 1.5, 1.5, 1.5, 0
make object box 2, 4, 4, 4
make object collision box 2, -2, -2, -2, 2, 2, 2, 0
position camera 1, 0, -10
position object 2, 6, 0, 0
do
gosub col
gosub keyctrl
sync
loop
REM controls
keyctrl:
if rightkey()=1
speedr#=speedr#+.004
zrotate object 1,wrapvalue(object angle z(1)-1)
else
speedr#=speedr#-.002
endif
if leftkey()=1
speedl#=speedl#+.004
zrotate object 1,wrapvalue(object angle z(1)+1)
else
speedl#=speedl#-.002
endif
if speedr#=<0.0
speedr#=0.0
endif
if speedl#=<0.0
speedl#=0.0
endif
position object 1,object position x(1)+speedr#-speedl#,0,0
return
REM sliding collision
function col()
oldposx#=object position x(1)
oldposy#=object position y(1)
oldposz#=object position z(1)
posx#=object position x(1)
posz#=object position z(1)
posy#=object position y(1)
position object 1,posx#,posy#,posz#
if object collision(1,2)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
endif
position object 1,posx#,posy#,posz#
endfunction
But now, with my collision, when a collision is detected and I continue holding right the cube slowly sinks further and further into the cube its colliding with... I've heard that DBP doesn't have very good built in collision though. Is that the problem?
Thanks!
Neeeeeeeewom!