Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Walking on staircase, how are they done in 2021?

Discussion in 'General Discussion' started by bitinn, Sep 9, 2021.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi,

    I am searching for some good tutorials/references for a third-person game where player walk on staircase. my 3 requirements are:

    - The walk should be smooth, so we avoid the sudden jump due to things like Step Offset.
    - The footing should be correct, so character feet don't float over stairs when stepping.
    - The process should be reactive, so character can handle a large variety of staircase, or slopes.

    Now, character animations aren't my main, so my assumption is, it will involve something like:

    1. Use a slope instead of actual staircase mesh for physical collider.
    2. But keep an accurate mesh collider for IK footing.
    3. Blend different pose if we want fancier animation in response to different stairs.

    Is this basically it? Any pitfall in my thinking? Any different approach in the wild?

    Thx in advance!
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,616
    This is what I'm doing in my current project, but it doesn't quite work because my stairs are too big compared to my character's legs. It's slightly tricky with ominously huge stairs because if your slope is too high then your character's IK feet won't always reach the stairs, and if your slope is too low then your character will pass through edges of each stair.
     
    bitinn likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Those steps are fine, but the most important part is to make sure you switch the animation to a different one that is designed for walking down / up stairs, and make sure the speed is less than the normal walking speed. IMO it is a requirement to "sell" the whole thing, since IK will probably be messy and imperfect.

    Here is an example in Yakuza 0 :


    (gah the forum code kill the time code, go to 0:20 seconds for an example of going down stairs, and at around 5:00 for going up a few steps)

    If I remember correctly they do no IK at all, although the camera really wants to go to a position where the feet aren't that visible :p
     
    Last edited: Sep 9, 2021
    Gekigengar and bitinn like this.
  4. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,789
    Your 1.2. steps are exactly what I'm doing, with my 3rd step being a custom stair-walk animation. The animation in step 3. need to be fine tuned with the width of the stairs, as does the movement speed. Also going up and down stairs each require separate attention, for best effect.
     
    bitinn likes this.
  5. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Foot IK is the best way to approach this I think, but the level of effort required for a good result is probably too much unless you have a lot of uses for good foot ik (lots of sloped ground).

    Looking at the yakuza example, I'm pretty sure that is almost nothing. A stock character controller with a step height, no animation, no fancy ik.
     
    Last edited: Sep 9, 2021
    Martin_H and bitinn like this.
  6. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Noob: wow how they did those AI they look phenomenal, must be hard!
    Actual pro: sweat profusely whenever at doors and stairs...

    I would also aligned the character to the direction of the stairs, basically see them as a kind of rails.
     
    bitinn likes this.
  7. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Rewatched the yakuza clip, I missed the 20s downstairs walk. That looks great, most of the work is being done by the head tilt. Can't see the feet themselves, so yeah they probably get away with no ik. The 5m example is just basic character controller, no add ons.
     
    AcidArrow and bitinn like this.
  8. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Is this a requirement, or a nice-to-have? This is the kind of thing where I see people make life unnecessarily hard for themselves.

    In much of the real world, staircases are in fact pretty standardised. Depending on the nature of your game, I find it hard to imagine players both noticing that your stairs are always the same rise:run and also caring about it.

    So instead of making a fancy technical solution to dynamically address arbitrary stair configurations, I would at least consider standardising my stair cases so you only have one problem to solve. Because then you can just have one set of animations for walking up/down stairs, it will fit all of your stairs, and the tech challenge is just recognising / synchronising that to stair cases. It'll still be a bit fiddly, but I suspect far simpler than the full arbitrary solver.


    But... one thing that your requirements list doesn't address: is the walking up stairs only going to be forwards / backwards? Because if you can also strafe up / down stairs, or walk on a shallow diagonal across really wide stairs, or other such things... then a full solver is likely going to be nicer than solving each case one-by-one.
     
    bitinn likes this.
  9. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Stairs in my prototype is dynamic at runtime, while they generally have the same step height (aka rise), they can have varied step length (aka tread), so the general slope of staircase can be very steep or very shallow.

    Good question, I didn't think of them initially, as my prototype doesn't have strafing.
     
  10. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    That seriously sounds like a case of making one's life more difficult.

    I'd just go with slope/mesh approach and call it done.
     
    GCatz likes this.
  11. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    This is very specific to my prototype, because it wasn't a game.

    My OP was asking about general implementation, because I want to know how others are doing it and what constraints they have.
     
  12. valarnur

    valarnur

    Joined:
    Apr 7, 2019
    Posts:
    438
    Do you happen to make collider around stairs in Blender? I thought this is way AA game studios are doing.
     
  13. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    I would use raycast against stair geometry. The thing is, if the animation is done right without IK, the player might not even notice if characters walk on slopes and their legs do not land exactly on stairs.

    Also you might need more than one raycast per foot to prevent toes from clipping into stairs.
     
    bitinn likes this.
  14. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I plan to use both a simple slope for physics and a mesh collider (using low poly mesh) for raycast IK.