Posted: 4th Sep 2003 3:52
change the intersect object to a variable such as:

intersect object(1,cx#,cy#,cz#,chx#,cy#,chz#)

to:

intersect object(obj,cx#,cy#,cz#,chx#,cy#,chz#)


There should only be two of these, one in the _collision sub routine and one in the _ramp sub routine.

Then before the routine is called, set the variable number like this:

+ Code Snippet
obj=10
gosub _collision

obj=20
gosub _collision

for obj=25 to 40
gosub _collision
next obj


At the moment, im trying to figure out how to make multiple objects and a camera can all use the collision but it just aint working for me Anyone know how to do this?
Posted: 6th Sep 2003 0:09
What you have to do is use the collision check function for each object and the camera. It will slow down the more times it's called, but that is the only way this code works. Once CShop gets a little more stable, I was going to make a Quake rip-off game using my collision as a tech demo. I'm still waiting to get bored enough to start it.

-Kensupen
Posted: 6th Sep 2003 3:46
Great stuff! Thanks for sharing.
Posted: 23rd Sep 2003 20:52
so er....
seems there are alot of modifications to this code.
Could sombody please post the final version of this code cheers.

Or...
Post the original and list all the fixes.. i just dont want to miss one thx
Posted: 30th Sep 2003 22:01
Ok, I've uploaded the code compiled for patch 5.1b. All the code is corrected to work in DBPro 5.1b. The download link is still on the first post. Let me know if anyone finds problems and I'll look into them.

-Kensupen
Posted: 30th Sep 2003 22:32
I wish you luck. I didn't even want to attempt this in DBC. Too much bubblegum and duct tape.


Ummm... yeah . Consider the dbc version officially too damn slow.
Posted: 1st Oct 2003 23:48
Kensupen,
'I might try to advance the code later to give a smooth height adjustment.'

In the remarks of this excellent code you mention smoothing the height adjustment. Any advance in this area..?

gbuilder.
Posted: 3rd Oct 2003 9:19
The only thing I was thinking of is making it add to the height until you were far enough away (I think I had 10 units) instead of just placing the camera/object at 10 units away.

-Kensupen
Posted: 3rd Oct 2003 11:24
Ok,
I've had some success going up stairs as well as ramps, providing the step is not too high. A bit jerky though as it adjusts to the new height..

gbuilder.
Posted: 3rd Oct 2003 21:10
I'm making a map in .X to use with your code (with some bad changes #) ) tej problem is the fps that REALLYY decrease.. first time I put a tree with 32000 polys!!!! LOL my mistake #) but even with 4 ou 5 trees with 900 polys the fps are really descrease.. I have a radeon 9700 but honestly I'm thinking that the problem can be mine.. because theres something strange with my radeon.. the fps decrease in other real games to.. confuse !! #)
Posted: 11th Oct 2003 16:01
Great bit of code Kensupen! My system only squeezed out 96 fps at sync rate = 0, but that's quick enough. Let us know if you fix that jumping routine because it keeps reseting to the start point.
Posted: 11th Oct 2003 21:16
this makes me want to buy dbpro

my system is dell 2.52 ghz, 256 ram, radeon 9500 pro / 9700 (128mb)
my fps averaged 75

this means that if i use this code and have dbpro i can make any level i want as .x format, and not need to do the teedy collision work myself?
what if i added an object during the game? during hte main do loop?
Posted: 12th Oct 2003 1:01
@Strider:
That isn't a jumping routine. It's to reset if you manage to walk out of the map or get stuck in a wall. I could add a jump into it if I get bored, or someone that knows how my code works could do it.

I won't have a lot of time to code in DB now. I just started a new job and it's taking up a lot of my time right now.

@Chris:
My code can be put into a function and you can pass any object to it and it would do all the sliding collision for you. That is why I wrote it. I was tired of not having BSP levels to play with, so I decided to see if DBPro could do the same thing with just an .X level made in CShop or a modeller. This code is what I came up with. It's only accurate to a 45 degree margin. (If a wall is rotated to 22.5 degrees the collision won't be accurate) You can make it accurate to any calculation of degrees, but you will take a massive performance hit. I figure 45 is good enough for any FPS game. Right now, I have it set to do 8 checks every loop for the level. If you add more objects to check against, you just multiply. I'd say 4 could be done without a massive performance hit. (At least on my system)

Play around with it and see what you can do. I made this snippet to help others that want to dive in a make a game but not have to worry about creating their own collision code.
Mine handles:
-Not being able to walk through any wall
-Sliding collision
-Camera height
-Gravity

-Kensupen
Posted: 12th Oct 2003 6:23
Dude,thats awesome
Posted: 12th Oct 2003 16:34
If anyone wants to see the code in action, check out my game. If this post is considered spam then i'll change it.

http://darkbasic.thegamecreators.com/?m=forum_view&t=18267&b=8
Posted: 12th Oct 2003 21:10
kensupen there is an oddity i noticed
when you are in midair when you go straight off a platform or ramp, you can control whether you move forward or backword while in midair.. you can stop and go in midair
Posted: 12th Oct 2003 22:52
also
when the height of an object is lower than your camera height, you hop onto that object if u move into it. this is a bit awkward as u can walk onto a ramp halfway
could you make it so that you walk onto the object if the object is a fourth as high as the camera, so u can only walk onto something if its a natural step height
Posted: 12th Oct 2003 23:22
a question and an observation comparing bsp with your code

in any professional engine ive played that uses .bsp, the computer freaks out when you are out in the middle of no where.. like bsps are only good in enclosed spaces

does .bsp does this in dbpro?

your code does not. i made a huge test map, my fps took no hit no matter what situation
Posted: 13th Oct 2003 1:31
Kensupen: This is really a great snippet. I tested it out - it kicks! Ya that midair movement thing is kinda odd Its an easy fix tho, just check the distance between the object and the nearest floor and if its greater then whatever, dont respond to up and down keys

Great work

RPGamer
Posted: 13th Oct 2003 23:17
Am I able to edit at what angle you cannot go up any more? It's set too high for me right now, you can go up some of my mountain slopes

How can I leave out an object from the collision?