I am having a problem with sliding collision. I used the sliding demo code as a base to work off of that comes with sparkys dll. My model is fine running on the maps and jumping but if it walks up a slope that is to steep he will not slide he just falls through the map. Also the model I am using does not stop near the edge of the objects, his limbs and half of the body enter the object before stopping. I changed the slope in the demo and that object will fall through the map as well. Does anyone know how to fix this and to stop a close to an object so the limbs do not go inside. Thanks for the help and here is the code.
`player object
load object "media/man.x", 1
position object 1,0,10,0
sc_setupobject 1, 0, 2
`make a object map to walk on
load object "media/map.x", 2
color object 2, rgb(0,255,0)
sc_setupcomplexobject 2,1,2
`ramp type object
make object cube 3, 25
zrotate object 3, 45
position object 3, rnd(50),10,rnd(50)
sc_setupobject 3, 1, 0
`ramp type object
make object cube 4, 25
zrotate object 4, 80
position object 4, rnd(50),25,rnd(50)
sc_setupobject 4, 1, 0
`ramp type object
make object cube 5, 25
zrotate object 5, 80
position object 5, rnd(50),rnd(50),rnd(50)
sc_setupobject 5, 1, 0
global gravity# = -.1
global slope#=.5
global ground=1
global jumptime#=0
global jump#=0
sync on
sync rate 60
do
gosub controls `handle player positions and controls
gosub camera `control the camera
gosub info `print info i need
sync
loop
controls:
oldx#=object position x(1)
oldz#=object position z(1)
oldy#=object position y(1)
if jump#=0 and jumptime#=0 then jump#=jump#+12*gravity# else jump#=jump#+gravity#
if keystate(17)=1 or keystate(31)=1 or keystate(30)=1 or keystate(32)=1
if keystate(17)=1 then set object speed 1, 30 : loop object 1, 10, 29 : move object 1,1
if keystate(31)=1 then set object speed 1, 20 : loop object 1, 10, 29 : move object 1,-1
if keystate(30)=1 then move object left 1,.3
if keystate(32)=1 then move object right 1,.3
else
set object speed 1, 10 : loop object 1, 1, 9
endif
if spacekey()=1 and ground=1 and jumptime#=0
jump#=jump#+3
jumptime#=20
endif
x#=object position x(1)
z#=object position z(1)
y#=object position y(1)+jump#
collide=sc_SphereCastGroup(1,oldx#, oldy#, oldz#, oldx#, oldy#+jump#, oldz#, .1, 0)
if collide>0
normy#=sc_getcollisionnormaly()
if abs(normy#)>slope#
oldy#=sc_getstaticcollisiony()
else
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
endif
if normy#>slope#
ground=1
jump#=0
else
ground=0
if normy#<-slope# then jump#=gravity#
endif
else
oldy#=oldy#+jump#
ground=0
endif
collide = sc_SphereSlideGroup(1, oldx#, oldy#, oldz#, x#, oldy#, z#, .1, 0)
if collide>0
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
endif
position object 1, x#, oldy#, z#
normy#=0
sc_updateobject 1
return
camera:
yrotate object 1, object angle y(1)+mousemovex()/3.0
set camera to follow object position x(1), object position y(1), object position z(1), object angle y(1)-180, -20, 5, 1, 0
return
info:
text 0,0, "Norm "+str$(normy#)
text 0,15, "Oldy "+str$(oldy#)
text 0,30, "Y pos "+str$(y#)
text 0,45, "X pos "+str$(x#)
text 0,60, "Z pos "+str$(z#)
text 0,75, "Ground "+str$(ground)
text 0,90, "Jump "+str$(jumptime#)
if jumptime#>0 then dec jumptime#, .3
if jumptime#<0 then jumptime#=0
return
mfield