Uploaded October 2016 | Updated November 2026, 23 hours ago
Whether or not a particular knife attack is a backstab is determined by the result of three vector dot products. This video should help show visually how all of this stuff operates, even for people who don't know what a "vector" or "dot product" is.
In the first video segment, the yellow vector is the horizontal part of the spy's aim direction ("SpyView"); the magenta vector is the horizontal part of the heavy's aim direction ("VictimView"); and the cyan vector is the horizontal part of the vector pointing from the middle of the spy's hull/bbox to the heavy's ("DeltaPosition").
The threshold between being considered "behind" or "in front of" the victim is when you're standing side-by-side, directly to the right or left of the victim (as if you're standing centered on a line extending out from the middle of the victim, perpendicular to their aim direction).
One curious finding is that as long as you're behind (see definition above) the victim, you can actually be facing slightly to their rear (17.5 degrees past perpendicular) and still score a backstab. This is best demonstrated in the beginning of the third video clip (at 3:20).
Since the vertical component of all the vectors involved is ignored, arguably-stupid things like backstabbing people while on top of them are possible. Because of the "behind" rule, it's only possible on the back half of their hull; and the other requirements become slightly more constraining than when you're on the ground beside the victim.
Yes, I know, it looks like the spy is trying to take a dump on the heavy's head in the fourth video clip. That's just what the duck animations do when you start and stop moving. Deal with it and leave your stupid comments to yourself.
Here's another very good analysis of spy backstab mechanics that's worth reading if you haven't seen it before. It's not 100% accurate about everything (e.g. the spy's aim direction does actually matter, and there's a hard 107.5 degree limit on reverse-direction stabs) but it's still largely correct and has some good diagrams and explanations:
technofovea.com/blog/archives/278
And here's what the actual code for backstab determination looks like:
gist.github.com/sigsegv-mvm/bda5c53af428878af6889635cd787332
Whether or not a particular knife attack is a backstab is determined by the result of three vector dot products. This video should help show visually how all of this stuff operates, even for people who don't know what a "vector" or "dot product" is.
In the first video segment, the yellow vector is the horizontal part of the spy's aim direction ("SpyView"); the magenta vector is the horizontal part of the heavy's aim direction ("VictimView"); and the cyan vector is the horizontal part of the vector pointing from the middle of the spy's hull/bbox to the heavy's ("DeltaPosition").
The threshold between being considered "behind" or "in front of" the victim is when you're standing side-by-side, directly to the right or left of the victim (as if you're standing centered on a line extending out from the middle of the victim, perpendicular to their aim direction).
One curious finding is that as long as you're behind (see definition above) the victim, you can actually be facing slightly to their rear (17.5 degrees past perpendicular) and still score a backstab. This is best demonstrated in the beginning of the third video clip (at 3:20).
Since the vertical component of all the vectors involved is ignored, arguably-stupid things like backstabbing people while on top of them are possible. Because of the "behind" rule, it's only possible on the back half of their hull; and the other requirements become slightly more constraining than when you're on the ground beside the victim.
Yes, I know, it looks like the spy is trying to take a dump on the heavy's head in the fourth video clip. That's just what the duck animations do when you start and stop moving. Deal with it and leave your stupid comments to yourself.
Here's another very good analysis of spy backstab mechanics that's worth reading if you haven't seen it before. It's not 100% accurate about everything (e.g. the spy's aim direction does actually matter, and there's a hard 107.5 degree limit on reverse-direction stabs) but it's still largely correct and has some good diagrams and explanations:
technofovea.com/blog/archives/278
And here's what the actual code for backstab determination looks like:
gist.github.com/sigsegv-mvm/bda5c53af428878af6889635cd787332









![[Raw: 2/2] Airblast-vs-Players: Vectors + Cone (essay in description)
This is some raw footage from a visualization mod I coded up and was messing around with the other day. It draws the vectors related to player airblast detection and the impulse imparted, plus the detection cone. (Read the rest of this video description for much more detailed info.)
For airblast versus enemy players to occur, the pyros aim/crosshair vector (cyan) must point within ~37 degrees of the vector pointing from the pyros WSC (hull middle) to the victims WSC (magenta). Its actually slightly more complicated than this due to the fact that the pyros aim vector is treated as if it comes out of his WSC rather than his head (where youd expect your aim to come from), but effectively it boils down to you must aim in a direction within 37 degrees of the middle of the enemys bounding box.
Why 37 degrees in particular? Because thats the arccosine of 0.8, and what the game actually does in mathematical terms is to check whether the dot product of the cyan and magenta vectors is greater than or equal to 0.8.
The mod shown in this video draws a cone 37 degrees wide, which represents the valid set of directions that the magenta vector can point where the airblast-push will be allowed to happen. The depth of the cone drawn does not accurately depict the effective range of player airblast; the actual limits are determined by the box shown in my projectile airblast detection box video: https://youtu.be/W1g2x4b_Byg
Impulse is a physics term that refers to a change in momentum; basically, for objects with constant mass, its just a change in velocity (speed and/or direction); and mathematically, its the integral of force with respect to time. As far as the Source engine is concerned, impulse is essentially just an instantaneous change to the velocity vector of the entity in question.
Its important to note that the way airblast modifies the velocity of the players it affects is very unrealistic: instead of adding the impulse vector to the entitys existing momentum vector, resulting in a *relative* change in motion that preserves some aspects of the entitys previous motion, the game instead first *completely zeroes out* the affected players velocity vector (cancelling all of their velocity, no matter how fast or in what direction), and then applies the airblast push impulse. This zeroing-of-velocity before the push impulse is applied gives the pyro increased control over the airblasted player, which can be a good thing for the pyro; however it also tends to result in an infuriating feeling for the airblast victim, whose movement is suddenly interrupted and then adjusted in an unrealistic manner that they dont have *any* control over.
In most normal situations, the pyro will be aiming somewhat horizontally at a player next to them, so the red vector will accordingly be horizontal as well. When combined with the vertical green vector, this will result in a diagonal yellow total force vector, at roughly a 45 degree angle upward.
At 2:45, you can see what happens when you airblast a player directly above you: the red vector now points straight up, since thats the direction from the pyro to the victim, and it has the same magnitude as before. And the green vector still points straight up with the same magnitude it had before (completely unchanged). So when these vectors are added, you get a total force vector that points upward, but which has in the neighborhood of ~1.4 times the magnitude of the regular diagonal airblast.
And at 3:00, you can see what happens when you airblast a player directly below you: the red vector now points straight down with the same magnitude as before. And the green vector still points straight up with the same magnitude it had before. Since these vectors point in opposite directions with approximately equal magnitude, their sum (the yellow vector) is very small, almost to the point that they cancel out. However, you probably noticed in the video that the airblast victim still gets pushed up a bit. Theres a reason for this, and it has to do with Valves fix for the groundstall situation that once affected the game. (See comments for explanation of this.) [Raw: 2/2] Airblast-vs-Players: Vectors + Cone (essay in description)](https://i.ytimg.com/vi/kXM32e4cNgA/mqdefault.jpg)
