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 Professional Discussion / Making an object (with gravity) go up and down a hill

Author
Message
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 3rd May 2010 15:41
Hi all,

I'm making a side scrolling game where the ground is not straight. I.E. it has lots of ups and downs so as to not make the terrain boring.

But after implementing the walking, the jumping and the gravity, I got stumped in how to make the protagonist go up and down the hill while walking. As in I don't know the logic behind coding it.

One method I was thinking is that for every hill, there are a lot of nodes on it where whenever the protagonist touches a certain node, moves it up or down. But thought that would be hard work, especially if the terrain is very bumpy (like made from 3Ds Max with Noise to create the terrain).

I also remember another method taught to me using a type of height map. But for now, I want to avoid using a height map since this is a side scrolling.

Can anyone help me? Thanks.
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 3rd May 2010 16:19
If you're reffering to not knowing the height of terrain, you should use raycasting.

If you don't know how to stop the player, I can draw you a skecth about the forces you need to apply to make it work.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 3rd May 2010 17:56
I meant like, imagine a person walking on a flat surface. His height doesn't move up or down right?

Now give that surface some hills. If I code it, the person would move "through" the hill rather than over it.

I want to know how to code it so that when the person reaches that hill, he will walk over it.
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 3rd May 2010 18:08
Well, first of all, since it's a side scroller (I imagine 2D) but you mention 3ds Max, so it sounds like you're making a 3D side scroller. If it's 3D, then I would check into Sparky's. It's a good starting point, and as TheBeely mentioned, the raycasting would work decent, though you could also use sliding collision.

www.myspace.com/norseblod
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 3rd May 2010 18:23
I don't think sliding collision would work good with friction and down-sliding (if a terrain is too "sharp" to walk uphill).
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 4th May 2010 09:42
Yeah it's a 3D side scrolling game. I have Sparky's but isn't Sparky just a better collision add-on?

And sorry but I'm not familiar with ray-casting and sliding collision?

How do they work? The terrains I have aren't sharp fortunately. The highest degree in which it begins to rise is probably like 5-10 degrees? Just slight rises in the terrain for a more realistic landscape.

Unfortunately I don't have any codes to show you guys since I don't know where to begin with implementing this =/

Would it be possible to show me a short demonstration of using ray-casting or something to achieve my desire? Or is it too complicated to do a mock-up?
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 4th May 2010 18:57
I threw this up for you. It uses built-in raycasting.

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 5th May 2010 11:20
Cool, that's almost exactly what I'm after yeah.

I'm studying the code and I'm still confused as to how your function figures out the height. I'll have to study it more and then get back to you guys.

Thanks a lot Thebeely ^^
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 7th May 2010 00:33
It was no trouble at all
Just look into the "intersect object" function.

Login to post a reply

Server time is: 2026-07-27 20:18:26
Your offset time is: 2026-07-27 20:18:26