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 / Object collision ground STUFF

Author
Message
bergice
17
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 16th Mar 2008 16:06
Hi, all!

I have made a terrain object for my ground with 3ds max and imported it to DARK BASIC.
I then made a cube as a player and fixed collision for it, so the box could walk on the ground object.

The only thing is that i made it so it decreases the height by 1 if it collides with the ground and increases it with 1 if it collides with the ground.

That is where the problem comes in.
When i touch the ground, the cube just bounces up and down.
But if i decreases the value of the collision, then in slopes it may fall through the ground.

How do i fix so that it doesnt fall through the ground and also keeps away from bouncing?

---:GAME MAKING IS BEST:---
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Mar 2008 16:22
Quote: "i made it so it decreases the height by 1 if it collides with the ground and increases it with 1 if it collides with the ground."


That doesn't make any sense.

If you hit the ground, you don't just increase the height - you set it to the collision height plus the walking height you want.

If it looks like it's bouncing then you could be using integers (which are probably too big a jump distance). Use floats so you can use collision height + 0.1 for example.

Without the code you are using it's just not possible to be any more accurate as you could have done anything.

So if you still can't get it working, use the search option or check out the tutorials - you'll find tons of info on the subject.

TDK_Man

bergice
17
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 16th Mar 2008 16:30
Quote: ""i made it so it decreases the height by 1 if it collides with the ground and increases it with 1 if it collides with the ground.""


Sorry, i ment the opposite.
If it collides it will move up and else it will move down.
I use that code because i need to make an object ground instead of a matrix ground

---:GAME MAKING IS BEST:---
bergice
17
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 16th Mar 2008 16:32
And btw, what did you mean by:
Quote: "you set it to the collision height plus the walking height you want"
?

And another thing is, if i dont make the cube bounce when it hits the ground then it will fall through the ground :S

---:GAME MAKING IS BEST:---
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Mar 2008 02:46 Edited at: 17th Mar 2008 22:07
Here's a very basic code snippet to show you the general idea:



TDK_Man

bergice
17
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 17th Mar 2008 18:33
Wow, that looks great!
I will take a look at that code and get it to my Database(brain)

---:GAME MAKING IS BEST:---
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Mar 2008 22:15
Sorry - I forgot to take out the two Text lines in the PositionCube procedure. You can delete them as they are not needed.

I also forgot to mention that I used a plain and a box as they are .X objects and you should be able to just alter the snippet so you load your landscape instead of creating objects 1 and 3.

You'll also probably have to alter the starting position of the cube so it's above the new landscape or you won't see it.

Other than that, it should work...

TDK_Man

Login to post a reply

Server time is: 2025-06-04 03:12:56
Your offset time is: 2025-06-04 03:12:56