Alright! Platforms are working!
I read a few ways to do platforms, and pretty much all of them involved using triggers. Triggers are invisible boxes (or spheres or capsules, but most commonly boxes) where as soon as you enter them, they execute some code in the game. In this case, people turn off collision whenever you hit a trigger below a platform and then turn it back on whenever you’re not in that trigger box.
I don’t really like that solution for a few reasons. It probably works fine in single player games, but in multiplayer games it’s a little goofy to just turn off collision for the entire platform. What if someone else is standing on the platform? Plus, what if you’re going super fast (as is likely to happen in Smash Bros. whenever you get hit at high damage) and actually skip the trigger box?
It took some brainstorming, trial and error, and fine tuning, but the way I’ve got it set up uses hit events. Whenever the character hits a platform, it asks a few questions. First is whether or not what it hit was a platform (conveniently, you can tag objects as platforms). Next it asks where the character hit the platform. Was it on the bottom of the capsule? If so, keep collision turned on. Otherwise, ignore that specific collision with that object and reset the velocity to what it was going to be assuming it never hit anything.
There are still a few things I’m not in love with about my platforms at the moment. One is that the animation looks a little goofy. In Smash Bros, pretty much every platform drop is a front flip of some kind, but for whatever reason it looks kind of silly in my game. I may change it to not play any animation and just go straight into JumpLoop, but for now I’ll just leave it as is.
The other problem is that when you’re in the air and holding down, you land on the platform for one frame. You can see it in the animation I posted above. I can’t really figure out how to stop that from happening, but to be honest it doesn’t feel bad in game. Once I get to playtesting, if it feels awkward then I’ll work on making it ignore that one frame of landing, but for now I think it’s probably good enough.
Next up…is air dashing!