Alright, I've scowered everywhere for a simple, FREE, sliding collision procedure.
- NGC sounds awesome but I really cant spend any money at the moment, I don't have any for starters and my parents wont invest in it right now.
- Sparky's Collision DLL is cool, I downloaded it but it isn't meant for sliding collision...Unless Aura finished that project that he was doing with it to make sliding collision.
- Joepy Dopy (Or whatever the Engine was called, I forget sry)'s Engine is cool but doesn't provide support for .x model collision, yet atleast. I'd attempt to get it to work but I'm too much of a noob to do that at the moment.
- Any other collision systems I've found are for DBC only.
I even made my own sliding collision system, which works fairly well with normal db models, but when I attempt to use .x models it works with some parts of the models and other parts it screws up. It can go around corners, and it has speed differentials (I.E if your looking almost right at the object you're running into, you'll slide slower than you would if you were to look say on a 45 degree angle.
For anyone that wants to check out what I've done so far with MY collision code, here it is below. Its fairly long, most likely sloppy, and so far I only have forwards movement calculated. (I.E if you were to move backwards into an object you'd go through it) But I can easily add that in later. Just don't feel like it right now especially since it isnt the greatest collision, and vibrates quite a lot.
NOTE: The smaller the amount you increase the user's X and Z, the less vibration there will be, but then the user will move slower. It's currently at 0.5 units.
NEW NOTE: I don't know how this happened but something got screwed with the code and some of the angle collisions are messing up, oh well w.e I'm not telling people to use this code, just putting it up incase people somehow find it useful.
`````````````````````````````````````````````````````````````````
`SLIDING COLLISION SIMULATOR: VERSION 1.0 `
`BY RUCCUS OF THE GAME CREATORS `
`````````````````````````````````````````````````````````````````
`IF YOU HAVE ANY QUESTIONS, FEEL FREE TO EMAIL ME AT `
`THE_CONJUROR@HOTMAIL.COM OR SUCCUR@GMAIL.COM `
`````````````````````````````````````````````````````````````````
`INCLUDES: `
`- SLIDING ANGLE COLLISION FOR MOVING FORWARDS `
`- SLIDING COLLISION AROUND CURVES AND CORNERS `
`- SPEED CHANGES FOR ANGLE OF COLLISION `
`- SLIDING COLLISION FOR .X FILE TO DB/DBP 3D MODEL `
`- SLIDING COLLISION FOR DB/DBP MODEL TO DB/DBP MODEL `
`````````````````````````````````````````````````````````````````
`FUTURE IMPROVEMENTS: `
`- SLIDING ANGLE COLLISION FOR BACKWORD+SIDEWAYS MOVEMENT `
`- MUCH LESS OR NO VIBRATION `
`- SLIDING COLLISION FOR .X FILE TO .X FILE `
`````````````````````````````````````````````````````````````````
`KNOWN BUGS: `
`- SOMETIMES, USER MOVES IN WRONG DIRECTION WHEN COLLIDING `
`````````````````````````````````````````````````````````````````
`NO ROYALTIES REQUIRES IF YOU USE THIS SNIPPET, (NO CLUE WHY `
`YOU WOULD IT ISNT THAT GOOD), CREDIT ISN'T REQUIRED BUT AS `
`ALWAYS A MENTION OF MY NAME (RUCCUS) IS ALWAYS NICE `
`````````````````````````````````````````````````````````````````
`SOURCE CODE`
`````````````````````````````````````````````````````````````````
`STANDARD SETUP FOR THE PROGRAM `
`````````````````````````````````````````````````````````````````
SYNC ON : SYNC RATE 0
HIDE MOUSE : COLOR BACKDROP RGB(000,000,000)
`````````````````````````````````````````````````````````````````
`VARIABLE DEFINITIONS `
`````````````````````````````````````````````````````````````````
FPS$ = "[]FPS: "
ANGLEX$ = "[]ANGLE X: "
ANGLEY$ = "[]ANGLE Y: "
ANGLEZ$ = "[]ANGLE Z: "
COORDX$ = "[]COORD X: "
COORDY$ = "[]COORD Y: "
COORDZ$ = "[]COORD Z: "
SLIDEX#=.5
SLIDEZ#=-.5
MAKE OBJECT CUBE 1, 100
MAKE OBJECT CUBE 2, 200
POSITION OBJECT 2,0,0,200
POSITION CAMERA 0,250,600
POINT CAMERA 0,0,0
`````````````````````````````````````````````````````````````````
`MAKE SURE COLLISION IS SET TO OBJECT 1, AND POLYGONAL `
`COLLISION IS USED FOR ANY OBJECTS WITH COMPLEX MODELS `
`````````````````````````````````````````````````````````````````
SET OBJECT COLLISION ON 1
SET OBJECT COLLISION TO BOXES 2
`````````````````````````````````````````````````````````````````
`BEGIN OUR LOOP `
`````````````````````````````````````````````````````````````````
DO `
`````````````````````````````````````````````````````````````````
`STORE OBJECT 1'S COORDINATES FOR LATER USE `
`````````````````````````````````````````````````````````````````
COORDX# = OBJECT POSITION X(1)
COORDY# = OBJECT POSITION Y(1)
COORDZ# = OBJECT POSITION Z(1)
`````````````````````````````````````````````````````````````````
`STORE OBJECT 1'S ANGLES FOR LATER USE `
`````````````````````````````````````````````````````````````````
ANGLEX# = OBJECT ANGLE X(1)
ANGLEY# = OBJECT ANGLE Y(1)
ANGLEZ# = OBJECT ANGLE Z(1)
`````````````````````````````````````````````````````````````````
`PUT SOME INFORMATION ABOUT THE GAME'S DATA ONSCREEN TO GIVE `
`US A BETTER UNDERSTANDING OF WHAT'S GOING ON `
`````````````````````````````````````````````````````````````````
TEXT 0,0, "SLIDING COLLISION SIMULATOR: BY RUCCUS"
TEXT 0,15,"GAME DATA"
TEXT 0,35,FPS$+str$(screen fps())
TEXT 0,50,ANGLEX$+str$(ANGLEX#)
TEXT 0,65,ANGLEY$+str$(ANGLEY#)
TEXT 0,80,ANGLEZ$+str$(ANGLEZ#)
TEXT 0,95,COORDX$+str$(COORDX#)
TEXT 0,110,COORDY$+str$(COORDY#)
TEXT 0,125,COORDZ$+str$(COORDZ#)
`````````````````````````````````````````````````````````````````
`CONTROLS `
`````````````````````````````````````````````````````````````````
IF UPKEY()=1 THEN MOVE OBJECT 1,4
IF DOWNKEY()=1 THEN MOVE OBJECT 1,-4
`````````````````````````````````````````````````````````````````
IF LEFTKEY()=1 THEN YROTATE OBJECT 1,WRAPVALUE(ANGLEY#-1)
IF RIGHTKEY()=1 THEN YROTATE OBJECT 1,WRAPVALUE(ANGLEY#+1)
`````````````````````````````````````````````````````````````````
`SLIDING COLLISION DETECTION AND PROCEDURE `
`````````````````````````````````````````````````````````````````
`IF OBJECT 1 COLLIDES WITH ANY OTHER OBJECT `
`AND THE OBJECTS ANGLE IS BETWEEN A GIVEN AMOUNT `
`AND THE USER IS STILL MOVING FORWARD `
`REPOSITION OBJECT 1 AT IT'S OLD COORDINATES + THE SLIDE VARS `
`````````````````````````````````````````````````````````````````
REM TOP -- RIGHT `
IF OBJECT COLLISION (2,1) AND ANGLEY# >9 AND ANGLEY# <81 AND UPKEY()=1 THEN POSITION OBJECT 1,COORDX#+SLIDEX#,COORDY#,COORDZ#+SLIDEZ#:SLIDE#=1
IF OBJECT COLLISION (2,1) AND SLIDE#=1 THEN SLIDEX#=-.5:SLIDEZ#=.5:SLIDE#=0
IF OBJECT COLLISION (2,1) = 0 AND SLIDE#=0 AND SLIDEX#=-.5 THEN SLIDEX#=.5
REM TOP -- LEFT
IF OBJECT COLLISION (2,1) AND ANGLEY# >279 AND ANGLEY# <351 AND UPKEY()=1 THEN POSITION OBJECT 1,COORDX#-SLIDEX#,COORDY#,COORDZ#+SLIDEZ#:SLIDE#=1
IF OBJECT COLLISION (2,1) AND SLIDE#=1 THEN SLIDEX#=-.5:SLIDE#=0
IF OBJECT COLLISION (2,1) = 0 AND SLIDE#=0 AND SLIDEX#=-.5 THEN SLIDEX#=.5
REM TOP
IF OBJECT COLLISION (2,1) AND ANGLEY# >349 AND ANGLEY# <361 THEN POSITION OBJECT 1,COORDX#,COORDY#,COORDZ#
IF OBJECT COLLISION (2,1) AND ANGLEY# >-1 AND ANGLEY# <11 THEN POSITION OBJECT 1,COORDX#,COORDY#,COORDZ#
REM BOTTOM -- RIGHT
IF OBJECT COLLISION (2,1) AND ANGLEY# >99 AND ANGLEY# <171 AND UPKEY()=1 THEN POSITION OBJECT 1,COORDX#+SLIDEX#,COORDY#,COORDZ#-SLIDEZ#:SLIDE#=1
IF OBJECT COLLISION (2,1) AND SLIDE#=1 THEN SLIDEX#=.5:SLIDEZ#=-.5:SLIDE#=0
IF OBJECT COLLISION (2,1) = 0 AND SLIDE#=0 AND SLIDEX#=.5 THEN SLIDEX#=.5
REM BOTTOM -- LEFT
IF OBJECT COLLISION (2,1) AND ANGLEY# >189 AND ANGLEY# <261 AND UPKEY()=1 THEN POSITION OBJECT 1,COORDX#+SLIDEX#,COORDY#,COORDZ#+SLIDEZ#:SLIDE#=1
IF OBJECT COLLISION (2,1) AND SLIDE#=1 THEN SLIDEX#=.5:SLIDEZ#=-.5:SLIDE#=0
IF OBJECT COLLISION (2,1) = 0 AND SLIDE#=0 AND SLIDEX#=.5 THEN SLIDEX#=.5
REM BOTTOM
IF OBJECT COLLISION (2,1) AND ANGLEY# >169 AND ANGLEY# <191 THEN POSITION OBJECT 1,COORDX#,COORDY#,COORDZ#
REM RIGHT
IF OBJECT COLLISION (2,1) AND ANGLEY# >79 AND ANGLEY# <101 THEN POSITION OBJECT 1,COORDX#,COORDY#,COORDZ#
REM LEFT
IF OBJECT COLLISION (2,1) AND ANGLEY# >259 AND ANGLEY# <281 THEN POSITION OBJECT 1,COORDX#,COORDY#,COORDZ#
`````````````````````````````````````````````````````````````````
`REFRESH OUR SCREEN AND END THE LOOP PROCESS `
`````````````````````````````````````````````````````````````````
SYNC
LOOP
`````````````````````````````````````````````````````````````````
`THE BREAKDOWN OF THE COLLISION IDEA `
`````````````````````````````````````````````````````````````````
`BASICALLY, I DREW UP A SQUARE ON A PIECE OF PAPER AND `
`CALCULATED EACH OF THE DIRECTIONS IT WOULD HIT AT, AND WHERE `
`IT SHOULD SLIDE TO IF IT DID `
`FOR EXAMPLE, IF THE USER'S Y ANGLE IS ANYWHERE BETWEEN 10 `
`AND 80 DEGREES, AND THEY HIT AN OBJECT, MOVE IT TO THE RIGHT. `
`THIS OFCOURSE WORKED, BUT I HAD TO CALCULATE HOW IT WOULD REACT`
`IF IT HIT THE OBJECT ON THE SIDE, IF I JUST USED WHAT I `
`CURRENTLY HAD THE OBJECT WOULD GO THROUGH THE OBJECT IT HIT. `
`SO, I DID A SECOND COLLISION CHECK. BASICALLY IF THE OBJECT HIT`
`ANOTHER OBJECT, IT WOULD MOVE RIGHT, IF IT HIT AN OBJECT AGAIN `
`THEN INSTEAD OF MOVING RIGHT, IT WOULD MOVE FORWARD. THEN I `
`JUST DID THE SAME PROCEDURE FOR EACH ANGLE, USING ADDITION AND `
`SUBTRACTION. `
`AS A FINISHER, IF YOU COLLIDE WITH ANOTHER OBJECT AT AN ANGLE `
`CLOSE TO 90, 180, 270, OR 360, STOP THE OBJECT SINCE IT'S `
`BASICALLY RUNNING INTO THE OTHER OBJECT. `
`````````````````````````````````````````````````````````````````
`TO SEE PICTURES OF WHAT I DID TO FIGURE OUT WHAT TO DO, `
`GO TO WWW.FREEWEBS.COM/RUCCUSCOLLISION `
`````````````````````````````````````````````````````````````````
Anyways, I cant figure out any way to get sliding collision to work. I recal seeing one forum post with someone saying "this is the 3rd and last time Ill post this...." with a link regarding sliding collision but I exited and forgot which it was and coudnlt find it again.
I know it's a lot of writing and it's asking a lot, but could someone please give me a hand with some sliding collision? Preferably working with .x to .x models. I dont need all of the code but possible a word explanation of what I need to do, and some tutorials out there that I havent found.
Thanks in advance.
Causin' RUCCUS whereva' I go.