Making Otto Slide Like Megaman
Right now I've been working on Otto's in-game slide, which basically follows the same mechanics as NES Megaman's slide. To be honest, I usually forget that Megaman can even slide, until I come to a point where it's necessary to continue. It makes me wonder if someone has gone through an entire game without knowing you can slide, but then again I think every Megaman has a part where you have to slide to continue. ANYWAYS, there are some key things to notice about Megaman's slide.
You slide by pressing DOWN + JUMP, where you will move in the direction you are facing for a short period of time, and unless you will collide with a tile then you stand back up. Also, your speed is slightly faster than your run speed and it allows you to squeeze through one tile's height(16 pixels). As you can see from the gif above, Megaman continues to slide until he can stand back up, and he can switch directions while sliding ONLY if the tile is directly above him. Let's write some psuedo code! First I check to see if I am touching the ground, not attacking, and not in the process of being hit. Then I check for key inputs of DOWN + JUMP, and I have Otto move in the direction he is facing while in the slide animation. Now I wasn't completely sure on when to stop sliding. Instead of a timer in the script or a certain distance moved, I just gave the animation a specific time length. Then when the animation is done playing, Otto will stop.
We don't want Otto to get stuck in the wall! So in Unity I have a trigger collider above Otto when sliding that checks if it is colliding with a tile. If it is true, then continue sliding AND allow Otto to change direction of sliding. The last thing to do is make sure Otto bleeds into the ground tiles just like Megaman!
Keep sliding on!