First, I would set up your level as a complex object (i.e. SC_setupComplexObject objNum , GroupNum , FacesPerNode). Set it as group 1.
Second, I would use sc_SphereSlideGroup:
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,y#,z#,radius#,0)
I revised the old demo code for Sparky's and made it so you can see how it can work by example:
// modified version of the slide demo for Sparky's
// LBFN 2/9/2011
sync on : sync rate 60
autocam off : hide mouse : randomize timer()
global NextObject, player : NextObject = 99
global radius# as float : radius# = 6.0
makeLevel()
makePlayer()
repeat
MovePlayer()
positionCameraToObject(2,view)
text 0,0,"Use W/A/S/D to move, and [spacekey] to quit"
sync
until spacekey() = 1
for obj = 100 to (NextObject - 1)
if object exist(obj) = 1 then delete object obj
next obj
end
function makeLevel()
// ground
temp = GetNextObject()
make object box temp,1000,20,1000
color object temp,rgb(0,255,0)
position object temp,0,0,0
sc_setupObject temp,1,2
TotalDebris = rnd(20) + 20
for m = 1 to TotalDebris
// get an object #
obj = GetNextObject()
// pick a random object shape
shape = rnd(4)
select shape
case 0
osize = rnd(20) + 10 : // get random spere size from 10 to 30
make object sphere obj,osize
x# = rnd(450) : if rnd(100) > 50 then x# = x# * -1
z# = rnd(450) : if rnd(100) > 50 then z# = z# * -1
y# = osize / 2
position object obj,x#,y#,z#
rotate object obj,rnd(360),rnd(360),rnd(360)
sc_setupObject obj,1,1 : // set it to sphere collision
endcase
case 1
osize = rnd(20) + 10
make object cone obj,osize
x# = rnd(450) : if rnd(100) > 50 then x# = x# * -1
z# = rnd(450) : if rnd(100) > 50 then z# = z# * -1
y# = osize / 2
position object obj,x#,y#,z#
rotate object obj,rnd(360),rnd(360),rnd(360)
sc_setupObject obj,1,0 : // set it to polygon collision
endcase
case 2
osize = rnd(20) + 10
make object cylinder obj,osize
x# = rnd(450) : if rnd(100) > 50 then x# = x# * -1
z# = rnd(450) : if rnd(100) > 50 then z# = z# * -1
y# = osize / 2
position object obj,x#,y#,z#
rotate object obj,rnd(360),rnd(360),rnd(360)
sc_setupObject obj,1,0 : // set it to polygon collision
endcase
case 3
osize = rnd(20) + 10
make object cube obj,osize
x# = rnd(450) : if rnd(100) > 50 then x# = x# * -1
z# = rnd(450) : if rnd(100) > 50 then z# = z# * -1
y# = osize / 2
position object obj,x#,y#,z#
rotate object obj,rnd(360),rnd(360),rnd(360)
sc_setupObject obj,1,2 : // set it to box collision
endcase
case 4
length = rnd(30) + 20 : width = rnd(30) + 20 : height = rnd(20) + 10
make object box obj,length,height,width
x# = rnd(450) : if rnd(100) > 50 then x# = x# * -1
z# = rnd(450) : if rnd(100) > 50 then z# = z# * -1
y# = height / 2
position object obj,x#,y#,z#
rotate object obj,rnd(360),rnd(360),rnd(360)
sc_setupObject obj,1,2 : // set it to box collision
endcase
endselect
next m
rem all level objects are group 1
endfunction
function makePlayer()
player = GetNextObject()
make object sphere player,radius# * 2.0
position object player,-80,radius# * 3.0,-20
sc_setupObject player,0,1
set alpha mapping on player,50
disable object zwrite player
rem player has no group
endfunction
function movePlayer()
rem rotate player with mouse
yrotate object player,object angle y(player) + mousemovex()/3.0
xrotate object player,object angle x(player) + mousemovey()/3.0
oldx# = object position x(player)
oldy# = object position y(player)
oldz# = object position z(player)
if keystate(17)=1 then move object player,1
if keystate(31)=1 then move object player,-1
if keystate(30)=1 then move object left player,1
if keystate(32)=1 then move object right player,1
x# = object position x(player)
y# = object position y(player)
z# = object position z(player)
rem player only collides with group 1 (level) objs and moves freely through others
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,y#,z#,radius#,0)
if collide>0
rem if hit, reposition player, halt movement vector
x# = sc_getCollisionSlideX()
y# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
rem re-position the player
position object player,x#,y#,z#
endif
sc_updateObject player
endfunction
function positionCameraToObject(obj,thirdPerson)
position camera object position x(player),object position y(player),object position z(player)
rotate camera object angle x(player),object angle y(player),object angle z(player)
endfunction
function GetNextObject()
repeat
inc NextObject
until object exist(NextObject) = 0
endfunction NextObject
Hope this is helpful.