Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / math collision problem

Author
Message
doffer
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 11th Jan 2004 23:56
Hi there.

I am making a little racinggame, kinda SWIW3d if someone can remember that((it's awsome (not mine anyway)). But i have a prblem. I made a plain i 3ds max, and then i streched some vertex's so it looks like hils, and then i exported it all over in dbc as one big mesh. Now when i make the "normal" collision, it thinks that i'm inside a box, and the top of the hils is where i should drive. I am non-experienced mathcollision guy, actually this i my first time, and i can't make it work. I can just drive through the hils.

I would be very pleased if someone would help me with my code, ore maybe just say what i have missed.

Denmark Denmark Denmark.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 12th Jan 2004 04:50
Math collision is a tricky one in DBC...

What you need to do is to make your own Get Ground Height function.

To do that you need to use collisions.

I'm not going to give you the code this time ( but if you get stuck, I can make some for you ), so that you learn how to do it yourself...


Firstly, this will all happen in the one function, before any sync command, so that user doesn't see what's happening.


Secondly, What you do, is you move the player object forward ( or backward, or whichever way it should move ) then you call the function.


Thirdly, the function itself...
Ok, this part is relatively simple, but requires a bit of doing...

Now that the object is in the posision that it is meant to be ( on the X and Z axis ) you want to position it on the Y axis.

So, you check for collisions.
1) You check to see if there are any collisions to start with.
( All of the collisions that you'll be checking will be between the player object [ i will call it obj ] and the ground object [ i will call it grd ] )
You check to see if obj is colliding with grd, and if it is, then you know you are near to where you want it to be...
So, you skip the next step, and go on to step 3.

2) Move obj so it is slightly higher than the highest point on grd
Now, bring the object down in a loop that move it slightly less than the objects height each loop. ( Ie, if obj had a height of 40, you'd move it at about 35 )
This way, you can't miss colliding with grd.
After each move, check for the collision between obj and grd...

3) Once the collision is detected, move obj up the same amount as you did in step 2 ( If you skipped step two; Ie, if obj had a height of 40, you'd move it at about 35 ). Then, move obj down in little amounts ( about 1 or 2 units per loop ) In a loop.
Untill, you detect collision again, then, move obj back up by the amount you were moving it down, and voila, you have your y posision.


You might want to put in a few checks when calling the function, to save on speed, but otherwise, you should be alright...

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
doffer
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 12th Jan 2004 16:09
Thanks a lot. You gave me a very good ide about how i should do it.

I'm glad you would take time and explain instead of just write the code.

Denmark Denmark Denmark.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 12th Jan 2004 19:44
That's cool, it's what I'm here for

Glad To Have Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-22 06:23:45
Your offset time is: 2025-05-22 06:23:45