Why Stairs Suck in Games... and why they don't have to

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] foreign to fall properly you need to get high this instructional video was prepared for everyone who does not feel high enough and is ready to do something about their situation climbing is as easy as doing yoga the major difference being oof that sounds too hard I think I'll take the stairs climbing too much upper body strength let me introduce you to stairs the best way to get high in video games like like higher elevation anyway I don't know if you pay way too much attention to physics and video games like I do uh you might notice when a set of stairs in the game is just a little bit off or maybe your character's foot kind of Clips through the ground or you get caught when trying to walk up something but really can stairs they can't really be that bad of a problem right I mean they've been in games for such a long time someone must have sorted it out well I mean you see the length of this video you might be asking yourself is Nick really going to talk about stairs for more than 11 minutes yes I thought stairs were simple at first too let's talk about why stairs suck in games and more importantly why they don't have to there are a few key things game developers can do to make the stairs easier to navigate and look much smoother but a lot of them don't do it I'm not saying that I've like solved stairs but I think I'm pretty darn close so before we dive into that let's first agree on what stairs are they usually look something like this on screen a set of steps at about a 90 degree or so angle to the ground and if it's less than 90 degrees you'd expect the player to slide up at like a slope if the player walks into an object at a 90 degree angle they probably want to stop because they're walking into a wall or something this makes sense however what if this walls low to the ground well then it's not a wall it's a step when the player encounters a step like this we don't expect him to stop like he does when he walks into a wall we expect the player to go up the steps smoothly it should look natural and not jittery it should be fast as well I mean even though the surface area of the step is more than that of a ramp walking up a set of stairs shouldn't be slower than walking up a ramp most built-in character controllers have support for stairs and this is important because this kind of a step isn't only found in a staircase and shows up more places than you might think at first I've dubbed this the stair problem as it's led to so many issues in developing my open KCC project so you might be thinking this already but what if we just hide the stair problem behind a ramp I mean isn't this like a lot of old video games did make the staircase into a ramp for the character controllers they can slide up at like a slope and then you can just round the edges of the character controller so they can bounce off any of those rough surfaces and there the character interacts realistically with mode terrain and you don't got to worry about it lots of games can get a way of doing this I mean even big branches like Pokemon OverWatch and Skyrim use these kinds of tricks for making their 3D worlds easier to explore if you add some inverse kinematics for the player feet to have them lock onto the ground with a little animating magic the player will hardly notice the hiding of the stair problem inverse kinematics is an animation technique to set the target position of a rigged Avatar and compute how the joints in the body positions would have to align to reach there think like if you stretch your hand out to grab something your elbow bends in a specific way to reach it and you know won't move like a brick or detach from your shoulder to reach it assuming the ik doesn't totally glitch out it should be fine have you put enough of these tricks together you can mostly ignore the problem of stairs from any video game scenarios some games even have their colliders float above the ground to make use of smoke and mirrors to kind of move the character visually down to the ground and just avoid the stair problem entirely so if hiding the stair problem works well enough let's try that we just need to replace the stairs for rant easy it'll take some work but it's just a one-time cost now wait a second it looks like you forgot something that little curve between the road and the sidewalk yeah that's also a step you don't want the player getting stuck whenever they try to walk into that so let's put a ramp there oh look on the side of that ramp for the staircase the the front corner if it's a little bit Jagged the player could get stuck on that unwell let's round that corner out so the players don't get stuck and now we have a million little things to correct about our map or just accept that some stairs can't be hidden easily don't even get me started on curved staircases games do take this crap path of beautifully crafting a world like breath of the wild and make sure that stairs are all interactive and responsive sometimes there are design flaws that the character can get stuck in but otherwise it works pretty well and if your character can't handle walking over some broken steps or jacket terrain just get rid of them or don't let them get too close to it but now you've just shifted the work of dealing of stairs from the character movement programmer to the level designer you can't really hide the stair problem you just put that work somewhere else now while some games may be able to get away with this problem on the level design my open KCC library is for any game developer to use and I can't just shift that work to anyone that wants to use it I mean I don't want to include a disclaimer this doesn't work with stairs unless you do x y z and I would rather just kind of solve the stair problem walking down steps is easier than walking up steps so let's look into that first when the player walks forward and they hit a staircase they should keep their feet glued to the ground of each step if we were to just move the player forward and not respect the steps at all the player would just start to move like a little bouncy ball going off the edge and then hitting the ground and off the edge and bouncing on top of the stairs even if we were place of a ramp this would still happen so to get around this problem for both steps and Rams we can simply snap the player down whenever they move after the player moves we check if the player is close to the ground then snap them down that way we avoid looking like a bouncy ball and leaving the ground whenever we go down a slope to snap the player down we just need a cast of the collider in a downward Direction similar to how we check if the player is grounded in my previous video about player movement then when they hit the ground we can check if it's within some small threshold and then we can just teleport the player down that distance however we can't apply this all the time think of like walking off a cliff you don't want the player to instantly snap down to the base we want them to fall normally additionally if the player is Falling Towards the ground we don't want to teleport them the last few inches away from the ground and snap them down because you know they'll just look weird we also need to turn off snapping if we're trying to jump I mean if we leave snapping turned on and we keep on jumping we just never leave the ground and that would just be embarrassing when snapping is added correctly we can walk down steps well and we're halfway to solving the stair problem woot oh yeah right we also need to go up steps too well we have that rounded collider idea from earlier let's see how well that works uh if we try and use this rounded collider it's not going to look very smooth you're going to kind of switch between bouncing up a step and then walking forward and you're not going to have a very constant velocity as you'll be switching between these two states very quickly it's it's kind of a mess and just doesn't look right and also what about overhangs I mean this is another Edge case to look at just like the street curve if we had an overhang we won't be able to just slide up it because it's a really Jagged Edge um this overhang scenario is like if the step the bottom of the step is behind the top of the step so it's kind of jutting out forward and there are also even more edge cases to consider that I didn't mention besides just overhangs I mean we could do the same thing as before and put this work on the level designer and just hide the problem but that's just shifting work and while this might work for some games I want to at least have a partially working solution to this half of going up the stairs as well so earlier we discussed about snapping down steps what if we just do the inverse and snap up steps so like whenever you hit a step have the player teleport up and then just go forward normally this solves the problem of bouncing off the step and moving at an inconsistent velocity we just need a way to figure out how to teleport the player to the top of each step we can use the Collision data to get the height of the step which even works for overhangs as well nice teleporting the player up to that height and then check if we walk forward the reason we need to check if we can walk forward some minimum distance is because if we don't and just let the player teleport up any solid surface they just walk straight up walls and cliffs we also need to set some limit to the maximum Step Up height to stop the player from climbing up low walls so from this we have two variables Max snap up height and Min snap distance snap height is the snap up height the maximum step height that we can climb up and the snap distance is the minimum step depth that we would expect to be walking on I mean you wouldn't be able to walk on a staircase at steps of just like a couple inches thick you need at least at some length put your toes on there otherwise you'd just slide right off we can use the same Collision algorithm as we used earlier for checking that when the player snaps down but instead going forward to check if we hit anything if there's Solid Ground to stand on in front of the player then we can let them teleport up and move forward if not we just leave them back at the base because they're probably walking into a wall we have to add a final little check to snap the player down after we teleport them up this is because otherwise they teleport up and could be floating on top of the step and then just fall down I mean that would just look kind of silly so this is done just like snapping down before and doesn't cost much to extra compute time so does snapping up and down solve the stair problem well as a lawyer might say it depends it works in most cases including some of the edge cases we discussed earlier it doesn't snap over walls allows for configuration of what's considered a step and works on the sides of ramps and overhangs however it does involve making more Collision checks whenever the player bounces into something so it's not free however adding an extra Collision check is so simple that it's not really a big issue whether you do three or four Ray casts on a player movement doesn't make that big of an impact sometimes if Collision physics is off and the player is in some kind of complex situation it won't work every time but we can hide those mistakes of a rounded collider and by using the neat tricks we discussed earlier like inverse kinematics for the player feed so overall I'd say snapping mostly solves the stair problem so now that you know the solution to the stair problem you shouldn't accept kind of bad stair implementations from your favorite video games developers can add extra polish like this if they're given enough time and resources if your character gets stuck clipping onto the edge of some small box or Ledge in the game you know it's because they never address the stair problem although I I really wouldn't be too hard on these game developers there are a lot of times under time crunch pressure and need to satisfy more stakeholders than just making a character look nice like I can do with my library with this knowledge you can look at some of the foot inverse kinematic Magics and games that you play you might be surprised about how many games use this trick to hide Collision detection um I should probably add that to my projects too now that I bring it up well I hope you found this discussion of the stair problem interesting I'll be making a video on how this mole character works coming up in the next couple weeks so subscribe if you don't want to miss it thanks for watching and have a great day
Info
Channel: Nick Maltbie
Views: 1,533,739
Rating: undefined out of 5
Keywords:
Id: ILVUc_yV24g
Channel Id: undefined
Length: 11min 23sec (683 seconds)
Published: Wed Feb 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.