I've been writing in certain forums for a while about the workings of TF2's "backstab" attack. Since there seems to be a lot of confusion and rage over this instant-kill-from-behind gameplay mechanic, I've decided to collect some of my findings here so I don't need to re-type them often. First I'll explain some basic concepts, and then show some diagrams to see how they add up to describing the backstab behavior.
Player collision hulls
How does TF2 decide when you bump into an enemy player? The hulls. These boxes (one per player) are also used to determine if you get hit by a projectile weapon, such as a rocket, grenade, or huntsman arrow. The collision hull is the big red box in these shots. (Ignore the blue box and white lines on the sides.) The player collision hull is the same size for all players! As far as TF2 is concerned, a Scout takes up just as much floor space as a Heavy.
For performance reasons, collision hulls don't "turn". They always face the same direction. This is a good thing: It would be really annoying if you had to turn your view to the side in order to get through certain doorways. However, it has implications for melee attacks as we'll see later.
Melee means invisible bullets hitting hulls
TF2's melee attacks appear to be implemented as a single powerful bullet that disappears after it travels a very short distance. Normally, when you think of "bullets", you think of the hitboxes used for most bullet-based attacks. But there's also another form of hitbox being used... Yes, the player hull we just saw! Although they're treated like a bullet, melee attacks use the player hull to determine if they hit an enemy. Why? Because if they didn't you'd have ridiculously harder time hitting anybody at close range.
The spy's knife has no firing delay
The Spy's knife is different from other melee weapons in a few ways.
- It can trigger backstabs. (Of course.)
- It usually does less damage.
- It cannot randomly crit to do extra damage.
- It shoots instantly without a windup time
The last one is important to know. The instant you click, the knife's "melee bullet" fires out. With other weapons, there's a delay and midway through the animation the "bullet" fires. It used to be different in earlier versions of TF2, and there are some good reasons that it changed which I won't go into here. (For historians, my notes say that the pre-patch knife either had a 1/8th or a 1/4th second delay, depending on the animation.)
The backstab angle is based on victim's aiming
The angle for a backstab is 180°, and it's based on where the spy is standing relative to where the victim is looking. And I do mean looking. The angle calculation has nothing to do with the player model, and everything to do with where the victim's crosshairs are pointing at the moment the spy attacks. In this next picture, I show you a Demoman who is about to be backstabbed.
As you can see, the victim's head and his weapon are what you must look at to know where they are aiming. Pay no attention at all to the feet and shoulders! That demoman is looking slightly away from you and can be be backstabbed with a single mouse click. (If he turns just a tiny bit to his right, he'll be safe.)
Lag compensation leads to "false facestabs"
In simplistic terms, a lag-compensated weapon (in TF2, anything that shoots bullets) is one which hits and does damage based on what the attacker sees, even if the attacker has high ping. If you are looking away from the spy the moment he clicks to attack on his screen, he'll get a backstab and you will die. If you happen turn around before his message gets to the server--and the server's "You're Dead" message gets to you--you will appear to be face-stabbed. This is similar to how people can complain about being "shot even though I had already run behind the wall" from some bullet weapons. On the Spy's screen, it's a perfectly legitimate kill.
- There are still "true" facestabs, which are a genuine bug rather than a subjective difference between players. I may make a followup post at some point on them if I can get a theory or two to pan out, but it seems most of the time it involves the Spy running at the victim and the victim backpedaling.
- Perhaps the best source for detailed information on lag-compensation and the game's networking model is found in the VDC Wiki.
How hulls and stabs come together
Map directions make a difference in melee attacks. Attacks will appear to "go farther" if you and your opponent are standing along certain directions. This top-down diagram shows why:
In both cases, the attacker and victim are the same straight-line distance from each other, but on a diagonal their melee attacks will appear to go farther because parts of their collision hulls are closer. Also, in the second example, they are actually bumping into each other. This is presented only to illustrate how things work: The overall effect is slight enough that I wouldn't bother worrying about it while playing the game.
The 180° angle with example stab
Now that you understand how melee attacks work, let's revisit the backstab's 180° angle limitation. This angle is calculated based on:
- Where the victim is looking
- Where the victim is standing
- Where the spy is standing
What's missing is this: It doesn't matter where the Spy is aiming... as long as his melee-bullet hits the enemy hull.
In this example, the Spy is "behind" is victim (as shown by the orange arrows) but his stab (purple arrow) still hits the victim's collision hull and counts as a hit. In fact, no matter which way the spy turns, as long as that purple arrow touches the orange hull he'll succeed.
- The same applies to stabbing from above or below an opponent. Vertical distance doesn't matter, as long as your melee strike hits them. So standing on their head can work as long as you are also are ever-so-slightly-behind them.
- All bullet weapons in TF2 fire from the eyeballs of the attacker. Along the crosshair's path. So if the enemy is below you, crouching can sometimes help if it brings your head downwards. (Insert obligatory joke about the Demoman shooting only a single fireball from his eye, while cursing the superiority of William Wallace.)