Posted: 27th Nov 2006 02:15
ok, now i'm havin trouble with static collision
i am goin off the static collision codes from the sliding collision example in db
i am making a third person game and im trying to keep the camera from going through the walls, it works but my character falls through the floors slowly as if there is a little bit of collision but not enough to keep my character from falling or going through walls and floors
here is parts of code from what i\'ve done, if you want all the code just let me know
`walls and floor
make object box 1,1000,5,1000
texture object 1,1
scale object texture 1,-40.0,-40.0
make object box 2,1000,1000,5
position object 2,0,500,500
texture object 2,2
scale object texture 2,-20.0,-40.0
make object box 3,1000,1000,5
position object 3,0,500,-500
texture object 3,2
scale object texture 3,-20.0,-40.0
make object box 4,5,1000,1000
position object 4,500,500,0
texture object 4,2
scale object texture 4,-20.0,-40.0
make object box 5,5,1000,1000
position object 5,-500,500,0
texture object 5,2
scale object texture 5,-20.0,-40.0
make object box 6,5,250,800
position object 6,10,125,100
texture object 6,2
scale object texture 6,-20.0,-40.0
`2nd through 4th floor
for t=0 to 2
make object box 7+t,505,5,800
position object 7+t,-245,247.5-(t*82.5),100
texture object 7+t,1
scale object texture 7+t,-10.0,-10.0
next t
`stairs
for t=0 to 19
make object box 12+t,25,2,50
position object 12+t,0-(t*25),249-(t*10),-325
texture object 12+t,1
next t
for t=0 to 19
make object box 32+t,4,10,50
position object 32+t,-12.5-(t*25),245-(t*10),-325
texture object 32+t,1
next t
for t=0 to 4
make object box 52+t,50,2,25
position object 52+t,-487.5,55-(t*10),-375-(t*25)
texture object 52+t,1
next t
for t=0 to 4
make object box 57+t,50,10,4
position object 57+t,-487.5,50-(t*10),-386.5-(t*25)
texture object 57+t,1
next t
stair collision
for t=0 to 19
make object collision box 12+t,-12.5,-1,-25,12.5,1,25,0
next t
for t=0 to 4
make object collision box 52+t,-25,-1,-12.5,25,1,12.5,0
next t
three floors collision
for t=0 to 2
make object collision box 7+t,-252.5,-2.5,-400,252.5,2.5,400,0
next t
`Collision boxes
make object collision box 1,-500,-2.5,-500,500,2.5,500,0
make object collision box 2,-500,-500,-2.5,500,500,2.5,0
make object collision box 3,-500,-500,-2.5,500,500,2.5,0
make object collision box 4,-2.5,-500,-500,2.5,500,500,0
make object collision box 5,-2.5,-500,-500,2.5,500,500,0
make object collision box 6,-2.5,-125,-400,2.5,125,400,0
make object collision box 11,-5,0,-5,5,0,5,0
make object collision box 233,-0.1,-12.5,-425,0.1,12.5,425,0
`make static objects
for t=1 to 8
make static object t
objx#=object position x(t)
objy#=object position y(t)
objz#=object position z(t)
objsx#=object size x(t)/2.0
objsy#=object size y(t)/2.0
objsz#=object size z(t)/2.0
make static collision box objx#-objsx#-objsx#-objsx#,objy#-objsy#-objsy#-objsy#,objz#-objsz#-objsz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
delete object t
next t
for t=12 to 61
make static object t
objx#=object position x(t)
objy#=object position y(t)
objz#=object position z(t)
objsx#=object size x(t)/2.0
objsy#=object size y(t)/2.0
objsz#=object size z(t)/2.0
make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
delete object t
next t
then in the main loop i have:
` keep camera out of collision boxes
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#,posy#-s#,posz#-s#,posx#+s#,posy#+s#,posz#+s#)=1
dec posx#,get static collision x()
dec posy#,get static collision y()
dec posz#,get static collision z()
if get static collision y()<>0.0 then playergrav#=0.0
endif