
V a = The acceleration to be added to V p. Keep in mind that we are only considering magnitude in this calculation, so the direction of the projection doesn't matter. V w = The direction that the player wants to move in (the so-called wish direction). V c = The current velocity before any calculations "Time 0" is on the top left, Time 1 is on the top right, etc. Let's model this mathematically:įigure 2: Using projection to limit speed. Recall that in order to airstrafe you must sync your movement keys with your mouse movement. This allows the player to exceed the maximum velocity in certain situations. I'll repeat here what I said before: Instead of limiting velocity directly, only the projection of the current velocity onto acceleration is limited. This is preferable because it is faster to perform than a cosine calculation. The dot product notation works because a dot product is equal to |a| * |b| * cos(Θ).
represents a dot product and b̂ is the unit vector of b (that is, a vector in the direction of b and a length of 1). Vector projection can be represented by the equation: V proj = |a| * cos( Θ ) = a This concept is illustrated below.įigure 1: Projecting vector a onto vector b The projection of a vector a onto a vector b (also known as the component of a onto b) is "The orthagonal projection of a onto a straight line parallel to b" (To quote Wikipedia). To explain this further, I need to first explain what vector projection is. Instead of limiting velocity directly, only the projection of the current velocity onto acceleration is limited. In the Quake III acceleration code, movement speed is limited in a very interesting and nonobvious way. Nevertheless it is still interesting to see the origins of the mechanic. Keep in mind that both codebases contain engine-specific code so they aren't as easy to integrate as the code in this article. If you would like you can check out the Quake III movement code or the Half Life 2 movement code on GitHub. It is possible in any game that is based off of the Quake engine, such as Source. Explaining Air Strafing MathematicallyĪir Strafing works because of the way movement acceleration is handled in the Quake Engine. It takes great skill and accuracy to perfectly sync your mouse movement to your movement keys. This explains in part why bunnyhopping is such a skill-based mechanic. The result of this from the player's perspective is a rapid increase in speed. That is, when he moves the mouse to the left he holds the a (left movement) key, and when he moves the mouse to the right he holds the d (right movement) key. When he does this, he syncs his mouse movement with his movement keys. In the clip above you may notice the player quickly wiggle his mouse left and right. The most important component of bunnyhopping is the concept of Air Strafing.
One Example of Bunnyhopping in Counter-Strike: Source ( Source)