Posted: 6th Dec 2003 00:42
Edited at: 6th Dec 2003 09:57
hey husky whats up
let me give a simple explanation
DarkBasic built in collision system is basically made to detect collisions with objects not matrixes. To detect a collision with a matrix first you must find the height of the matrix. For doing that theres a special function call (get ground heigt(matrixnumber,x,y))
look up the function in DB built in help to get full explanation.
Heres an example
`setup
sync on
sync rate 30
backdrop on
`make matrix for testing
make matrix 1,5000,5000,20,20
`make object for testing
make object sphere 1,10
`make variables for gravity and boost
gravity#=1.0
boost#=2.0
`main loop
do
`define object position and angle
px#=object position x(1)
pz#=object position z(1)
py#=object position y(1)
ay#=object angle y(1)
`get ground height function
matheight#=get ground height(1,px#,pz#)
`add gravity to pull object down
py#=py#-gravity#
`add some boost to move object up
if upkey()=1
py#=py#+boost#
endif
`heres where collison is detected
if py#<=matheight#
py#=matheight#
endif
`position object at new positions
position object 1,px#,py#,pz#
`create new camera positions
cx#=newxvalue(px#,ay#-180,20)
cz#=newzvalue(pz#,ay#-180,20)
`position camera at new position
position camera cx#,py#,cz#
`point camera at object
point camera px#,py#,pz#
`print positions to screen
set cursor 0,0
print "px#",px#
print "py#",py#
print "pz#",pz#
print "ay#",ay#
print "matheight#",matheight#
print "cx#",cx#
print "cz#",cz#
`update screen
sync
loop
`that should give an idea