Third, the trickiest part of adding hitboxes was also adding hitlag for the attacker. Hitlag is the brief amount of time between landing a hit and the opponent going into knockback/hitstun. Even though when most people talk about hitlag, they’re talking about the person who got hit, in actuality both the attacker and the victim go through hitlag. During this short time, both the attacker and the victim are almost completely frozen in place.
I explained this mechanic to a few friends of mine as I was struggling to get it working properly, and a common question was, “Why is hitlag important? Do you really need it?” Hitlag does a few things. The first thing, and the reason why you see it in every fighting game (and even most video games in general), is that it makes the game “feel” better. When you land an attack and the game pauses briefly, it makes you feel like your attack had weight behind it. It feels like it was a big deal that your attack landed, and it also gives you a little bit of time to react to your attack actually landing. A neat thing in Smash Bros. is that there is more hitlag on moves that deal more damage, so the stronger the move the more satisfying the hitlag feels.
The other reason why hitlag is important is something that is unique to Smash Bros. Smash Directional Influence (SDI) is an advanced technique that is only possible because of hitlag. During hitlag, the victim is able to teleport a very small distance if they are able to press the control stick during the 3+ frames they’re in hitlag. When you first learn about SDI and see it in action, it feels very underwhelming, but at higher levels of play it has some very important uses. It ends up being a subtle, but very interesting counterplay option given to the player that got hit. In Brawl it was extremely strong, as you can see in this video by MrDoom8000. Many of the clips in this video show him SDI’ing several times over the course of a small number of frames, and many times it’s the only reason he survives. In most of the other Smash games it’s not nearly so dramatic, and even in Brawl this guy’s SDI is insane. Still, it’s a really fun option to have, so it’ll be included in my game as well.
Anyway, what made hitlag rough had to do with how I originally handled hitbox timers. Imagine this scenario: Your attack’s hitbox only lasts for 3 frames and you hit on the first frame possible. You and your opponent are stuck in hitlag for let’s say 4 frames. If you have your hitbox timer set up to only last for 3 frames, it will go away before hitlag has even ended, which means that the last frame of hitlag and also the other 2 frames of the attack are suddenly hitboxless. So what do you do? You can’t just add 4 frames to the hitbox timer, because what if on the next frame another person gets hit? In this case you are stuck in hitlag for another 4 frames (so a total of 5), but you’ve added 8 frames to your hitbox timer. In this case you’ll get an extra 3 frames of your attack where the attack has a hitbox and shouldn’t.
Ideally what I wanted to use was one of the timer or timeline functions pre-built into Unreal Engine 4, but in the end I couldn’t get any of them to work. They either wouldn’t work at all, or worse the timer would be slightly inaccurate. I ended up building my own independent timer that works fine and can be paused, but I was really hoping to use one of the ones already in the engine. I’m sure the problem was between the keyboard and chair, but it was frustrating while I was working on it. Anyway it’s working now, and that’s what matters.
Fourth, I’ve done a handful of smaller things as well. Among them, I changed the Landing and Jab1 animations slightly. I made landing stay close to the ground for 2/3 of the animation so that if you jump again it doesn’t look awkward, and with Jab1 I made the punch snap into place a bit more. It gives the jab just a little bit more force behind it.
So what’s next? Going off of last week’s post, the things I haven’t gotten done yet are hitlag (on the victim’s side), hitstun, knockback, and being able to control two players at once. Although I mentioned it last, all of this is sort of under the “Get two player working” umbrella, so I expect it to be a whole project. I generally know how I want all of that stuff to be done, but I’m sure it’ll be a challenge.
Oh, and the camera will have to be redone as well to accommodate two players instead of one, which is another project. It’s very tempting to just go back to making attacks and throwing them in the game, since I did all this work in order to be able to do that, but on the other hand having two player working will be a huge relief. Hard to say what I’ll do, but for now I’m going to step away and take a break. Tomorrow I’ll decide what the next project is. Thanks for reading!