[center]!SLIDING COLLISION FOR CLASSIC AND PROFESSIONAL![/center]Hello guys, I decided to make life easy and make up a couple of functions for sliding collision. I always hear people asking for help with sliding collision, but I dont think that will be needed anymore.
Now there are two different snippets! One works in pro, and one works in classic. Cheers guys! Here is what I ran this on,,,
System Specs:
Pentium 3
512 Ram
GeForce 2
With a sync rate of 80 I was running at a solid 90 FPS in pro, and a solid 83 in classic

[center]
Here is the collision code for PROFESSIONAL[/center]
+ Code SnippetREM Example code
sync on
sync rate 80
hide mouse
make matrix 1,2000,2000,1,1
Make object Cube 1,40
Position object 1,250,0,250
Collbox(1)
Make object sphere 2,20
Position object 2,0,0,0
Collbox(2)
do
`Gotta move that dude
yrotate object 2, camera angle y()
if upkey() = 1 then move object 2,4
if downkey() = 1 then move object 2,-4
yrotate object 2,wrapvalue(object angle y(2)+90)
if leftkey() = 1 then move object 2,-4
if rightkey() = 1 then move object 2,+4
SlideColl(2)
posx#= Object Position X(2)
posy#= Object Position Y(2)
posz#= Object Position Z(2)
position camera posx#,posy#+20,posz#-40
sync
loop
`this is the function for the collision box
Function CollBox(ob#)
obsx#= Object Size X(ob#): Rem Find the object size X
obsy#= Object Size Y(ob#): Rem Find the object size Y
obsz#= Object Size Z(ob#): Rem Find the object size Z
Make object Collision Box ob#,0-(obsx#/2),0-(obsy#/2),0-(obsz#/2),(obsx#/2),(obsy#/2),(obsz#/2),0
endfunction
`Now that the collision box is made, the function can be put in the main loop
Function SlideColl(pn#) : Rem pn# is PLAYER NUMBER
obx#= Object position x(pn#) : Rem Get the objects X position
oby#= Object position y(pn#) : Rem Get the objects Y position
obz#= Object position z(pn#) : Rem Get the objects Z position
If object collision(pn#,0)>0 : Rem here you may put NOT any objects you dont want collision with
dec obx#,get object collision x()
dec oby#,get object collision y()
dec obz#,get object collision z()
position object pn#,obx#,oby#,obz#
endif
endfunction
Code should work as pasted in pro.
[center]
Here is the code for classic[/center]
+ Code SnippetREM Example code
sync on
sync rate 80
hide mouse
make matrix 1,2000,2000,1,1
Make object Cube 1,40
Position object 1,250,0,250
ob#=1
Collbox(ob#)
Make object sphere 2,20
Position object 2,0,0,0
ob#=2
Collbox(ob#)
do
`Gotta move that dude
yrotate object 2, camera angle y()
if upkey() = 1 then move object 2,4
if downkey() = 1 then move object 2,-4
yrotate object 2,wrapvalue(object angle y(2)+90)
if leftkey() = 1 then move object 2,-4
if rightkey() = 1 then move object 2,+4
SlideColl(ob#)
posx#= Object Position X(2)
posy#= Object Position Y(2)
posz#= Object Position Z(2)
position camera posx#,posy#+20,posz#-40
sync
loop
`this is the function for the collision box
Function CollBox(ob#)
obsx#= Object Size X(ob#): Rem Find the object size X
obsy#= Object Size Y(ob#): Rem Find the object size Y
obsz#= Object Size Z(ob#): Rem Find the object size Z
Make object Collision Box ob#,0-(obsx#/2),0-(obsy#/2),0-(obsz#/2),(obsx#/2),(obsy#/2),(obsz#/2),0
endfunction
`Now that the collision box is made, the function can be put in the main loop
Function SlideColl(pn#) : Rem pn# is PLAYER NUMBER
obx#= Object position x(pn#) : Rem Get the objects X position
oby#= Object position y(pn#) : Rem Get the objects Y position
obz#= Object position z(pn#) : Rem Get the objects Z position
If object collision(pn#,0)>0 : Rem here you may put NOT any objects you dont want collision with
dec obx#,get object collision x()
dec oby#,get object collision y()
dec obz#,get object collision z()
position object pn#,obx#,oby#,obz#
endif
endfunction
Both those you should be able to paste right in and have work.
Hope you people get some use out of this. This was just made in a few minutes, not a final version at all. Probably wont even keep it........ But anyways I hope you like it!
EDIT: The first time I pasted I messed up,,,,it doesnt work in the SOURCE box,,,Ill post again. The code in the code snippet part should work though,,works for me when I copy and paste.
RPGamer