Game Development Community

How do you go about programming stairs?

by Zachary "Skids" Taylor · in Game Design and Creative Issues · 09/15/2004 (6:41 am) · 9 replies

I'm working on a game, but am stuck on how to get my character to walk up stairs without walking up walls. Do any of you know anything about a good algorithm for making something like that work?

About the author

Recent Threads


#1
09/15/2004 (6:51 am)
Hmmm - either make the stairs as interior shapes that you can actually walk up, or hack the player class. Use a trigger around the "stair shape" and when the player is inside a "stair" trigger, remap/recode the movement behaviour

Thats how I would approach it, but I bet there are tons of other ways to do it
#2
09/15/2004 (9:04 am)
A simpler way (at least from my non-programmer point of view) would be to specify a maximum height transition that the player can traverse. If I recall correctly, this is essentially how it is done in the Unreal engine, for example. The problem I see with creating a stair class is that mappers would have to set those triggers up at every instance of a step, even if it's just a shallow curb or something.
#3
09/15/2004 (9:13 am)
@Teck Lee Tan: If I'm not mistaken, this can be set up in default TGE too. Somewhere in the player datablock, can't remember which one though.
#4
09/15/2004 (9:17 am)
To rebut my own point, there are cases for setting up specific stair class type things. Off the top of my head, I'd say for stuff like a third person adventure type of thing, where you want to showcase proper animations when going up/down a flight of stairs (as opposed to the typical walking/running on flat ground anims).
#5
09/15/2004 (9:51 am)
An even simpler solution if you're not opposed to "cheating" and the stairs are small are to put an invisible ramp on them.

--\
  | \
   --\
     | \
      --\
#6
09/15/2004 (11:01 am)
Uh, guys, steps are already in the engine, and always have been.
// Try stepping if there is a vertical surface
Somewhere very close to the above code, you would probably want to add some animation calls for a more visually pleasing result, but otherwise it works just fine. The datablock contains the maximum height a player can step. Tweak to your hearts desire.

edit: removed code line. I didn't notice this was the public forum.
#7
09/15/2004 (11:05 am)
Greetings!

That's of course assuming that Zachary is using the TGE or TSE. I would assume not, otherwise he wouldn't be having an issue.

Eric, it would be best not to post code from the TGE/TSE in a non-SDK forum as that breaks the EULA.

- LightWave Dave
#8
09/15/2004 (11:05 am)
From this article (a good read) www.gamasutra.com/features/20010324/melax_01.htm

Quote:
I solved this by lifting up the path of the player when it collided with something. If the raised path was clear I'd move the player along it and then drop it back down. I thought this was just a temporary fix when I first implemented it during our prototype stage, but it worked beautifully and ended up in the final code that was shipped.

That is essentially what TGE does also.
#9
09/15/2004 (11:49 am)
@David: I think Zachary is using DarkBasic