Skip to content


TF2 Backstab mechanics

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.

The collision hull (red) and hitboxes (multicolored) for 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.

  1. It can trigger backstabs.  (Of course.)
  2. It usually does less damage.
  3. It cannot randomly crit to do extra damage.
  4. 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.

This is a marginal backstab. The demoman is actually facing slightly away from the Spy, as evidenced by the direction of his weapon and head.

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.

EDIT:

  • 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:

Melee attacks appear to go farther on diagonals

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:

  1. Where the victim is looking
  2. Where the victim is standing
  3. 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 successful backstab, the Spy is actually looking a little bit "away" from his victim.

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.

EDIT: .

  • 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.)

Posted in Games.

Tagged with , , .


19 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Pirahna-Plantman says

    The only thing it doesn’t explain is how a spy can net a facestab on victims there were backing away from a spy. If I’m to follow the mechanics of the game the spy’s hull is looking toward the victim’s hull so the backstab should impossible. Unless the spy’s hull is colliding with the victim’s hull literally so that the melee *bullet* collides with the rear end of the victim’s hull with some lag compensation to get a face stab. Otherwise everything else was well done.

  2. anonymous says

    good stuff

  3. Keith says

    Awesome. Do you know what the rules are with regards to vertical height? I’ve always been disappointed at my flying-off-a-cliff-jump-on-the-back failstabs :(

  4. Darien says

    Piranha: I’ve been toying with some theories for a while what might cause lag-compensation to interact with the backstab-yes/no code in that case, and I might try a followup post on it at some point if it makes sense.

    Keith: For a brief time Valve tinkered with the vertical stuff (and then reverted their changes) so AFAIK there aren’t any vertical rules, except what you’d expect in terms of “did the melee-bullet hit the box”. So if you stand on top of someone and one inch “behind” them, you can still look down just enough to hit their collision box and get a backstab.

  5. TJ says

    Following up on what Darien was saying, Keith: The same thing can happen from underneath. However, if you’re ontop, the range of your ‘bullet’ isn’t from your arm to your toe, so you have to compensate and make that distance shorter.

  6. Kilranian says

    Darien: In response to your last comment, typically a spy has to crouching to land a stair-stab or vertical-backstab. As such, it leads me to believe that the bullet is leaving the spy’s “hands” and the bullet’s distance is exhausted before it reaches the opponent’s hull.

  7. Reid says

    Awesome, this perfectly explains all the questionable backstabs I’ve seen. Usually you’ve spotted the spy and he’s circling you trying to get you to look away and you’re frantically keeping your camera on him. Then on his screen, he catches your back, and when you get told you are stabbed, he’s on your screen.

  8. News says

    Why dont they make the hulls a cylinder in tf2? To nerf scouts?

  9. Lia says

    Thanks! Interesting post. However: “This topic can sometimes be a bit mind-bending and controversial, especially for non-programmers, so I’ll try to keep it short.” Don’t do this. The reader can decide for himself and skip if the part is too complicated. The mechanics of the lag compensation would have been interesting to know…

  10. Curley says

    Somewhat off topic, but I figured since you’ve been looking into melee, you might know the answer. Do all the melee attacks have the same range? For example, the Ubersaw attack looks like it has a longer reach than say, the Bottle, but as far as TF2’s concerned, does it actually have a longer reach?

  11. Darien says

    Kilranian: I’m pretty sure the “bullet” is–like almost all others in the Source engine games–fired from the head of the player. Like laser eyes. While this leads to some weird stuff (like a Heavy easily tearing you apart as he peeks over a low wall) it ensures that bullets travel directly along the crosshair and makes close-range headshots possible.

    Anyway, that would explain why crouching is important when going for a stab from above.

    Reid: I do want to mention that “true” facestabs–ones that are wrong even from a technical perspective–are real and have been occasionally reproduced. But the majority are probably “false” ones caused by lag-compensation which don’t look wrong to the attacking spy.

    News: Not sure. Probably legacy reasons, and it might lead to trickier physics. An octagonal prism could have been a good compromise.

    Lia: There’s some good information on the Valve Developer Community Wiki.

    Curley: Not sure. I’d guess most are identical, but there’s no reason Valve couldn’t have programmed different weapons to have a different ranges if they wanted. It should be pretty straightforward to test with bots.

    _____________

    I’m playing with some old theories about “true” facestabs and looking over some of the diagrams I made, but in a way what I really need to do is make it an animation or slide-based flipbook because it gets confusing. You’ve got the client’s point-of-view, the server’s point of view, and the server’s guess at at what the client saw… and players moving through time and along a line.

  12. Viral says

    Thanks for this article, nice and detailed (with great illustrations).
    After reading this my backstabbing improved.

    Looking forward to more articles about the intricacies of TF2 (if there are going to be any, I for one would love it).

  13. Jeziah says

    I have hypothesized myself on backstabs, facestabs and sidestabs, and all my speculations are easily explained by your model.

    My ideas focused on the fact that the playermodel stands with a twisted (to the LOS) back, and without any idea of the “collision hull” I assumed that to compensate the developers counted the back AND outwards-facing sides of the right-arm (which is somewhat behind the playermodel on most characters, as it is the “trigger” hand and does not extend as far as the other, which steadies the weapon) as the back for backstabs. This explained the visual phenomena of the sidestab, which APPEAR to occur from the right side because of the twisting of the playermodel.

    Of course thats all moot now, I just thought it’s interesting how simply your model explains my own seperate observation and concern (the apparent ease of sidestabs from the right (spy left)), compared to my own- a sign that you have undoubtedly found the true mechanic!

  14. discrider says

    I’m sort of sick of seeing articles based around “false facestabs”. Sidestabs are not false facestabs or facestabs of any sort. The two are different, so stop using the word facestab in relation to any sidestabs at all. It just perpetuates the myth that fixing sidestabs would fix facestabs and failstabs and gives us stupid Valve fixes.

    Though I suppose that’s not the author’s fault. So nice collation.

    Still, in relation to the actual article content, I don’t understand why my backstabs on my home computer are so different to the backstabs in town on a lan or those described here. For some reason, my backstabs act just like they did pre-instastab patch. When the knife falls, so does the victim. I can turn my knife mid-swing and everything. Yet in town, people just fall over dead as soon as I press the button.
    Something weird is going on here with lag or latency, but I have no idea what.

  15. frozen_ says

    Very well written, makes understanding this matter a lot easier. I’ve just one, non-backstab related question: the huntsman arrows use the collision hull, rather than the hitboxes? Looking at your heavy picture, this would mean my arrow would hit/kill the heavy even if it hits the corner of said hull…and thus, doesnt hit the model at all. But i’ve yet to see such a huntsman hit/kill…isn’t it possible that the huntsman uses the hitboxes as well?

  16. Darien says

    the huntsman arrows use the collision hull, rather than the hitboxes

    As far as I can tell it does. See this video.

    The final arrow location isn’t directly representative of where the arrow hit, since it always goes through the center of a player bone.

  17. cy3 says

    What this article says can be extended to show how you can stab an enemy while you are in front of him.
    Not that I’ve mastered that yet, of course…

Continuing the Discussion

  1. uberVU - social comments linked to this post on March 16, 2010

    Social comments and analytics for this post…

    This post was mentioned on Reddit by CarbonFire: TF2: A Science….

  2. ubercharged.net – Facestabs explained? linked to this post on March 17, 2010

    […] “fixing” the problem), facestabs still exist. Thanks to the brave muckraking efforts of Sesquipedalian, it looks like we might yet have an answer as to why the problem occurs, though as of now, no […]