Yes, that is how one would rotate a collision box, technically, but with such a basic question I can only assume that nightowler isn't all that familiar with DarkBASIC's collision system. DarkBASIC's built-in sliding collision functions only work with non-rotated collision boxes. For high quality sliding collisions against complex objects, I would recommend the use of the
ColDet library, which I used for the collisions in
Dark Survival 2. However, I predict that it would probably take you a long time to adapt DS2's collision routines into your game, and even longer to make them from scratch using ColDet. In that case, there is a commonly-used method that does not involve such complex code. It involves the use of a non-rotated box for the player's collisions and 3 calls to
object collision() per loop, one for each axis. The
July release of the Dark Survival 2 demo used that method 2-dimensionally. Here is an applied example of the key parts of the collisions used there:
sync on
make object cube 1,1
set object collision to polygons 1
make object cylinder 2,-20
set object collision to polygons 2
make object plain 3,20,20
set object collision off 3
color object 3,rgb(0,255,0)
xrotate object 3,90
position object 3,0,-0.5,0
xrotate camera 30
colbox=1
do
prot#=object angle y(colbox)
if leftkey() then dec prot#,3
if rightkey() then inc prot#,3
prot#=wrapvalue(prot#)
yrotate object colbox,prot#
oldx#=object position x(colbox)
oldz#=object position z(colbox)
if upkey() then move object colbox,0.5
if downkey() then move object colbox,-0.5
newx#=object position x(colbox)
newz#=object position z(colbox)
yrotate object colbox,0
if checkcollision(colbox,newx#,oldy#,oldz#)>0
newx#=oldx#
endif
if checkcollision(colbox,oldx#,oldy#,newz#)>0
newz#=oldz#
endif
position object colbox,newx#,newy#,newz#
yrotate object colbox,prot#
yrotate camera prot#
position camera newx#,newy#,newz#
move camera -5
sync
loop
end
function checkcollision(i,x#,y#,z#)
position object i,x#,y#,z#
result=object collision(i,0)
endfunction result