Bunnyhopping For Noobs

its a feature

Posted by 2nafish117 on July 09, 2021 · 5 mins read
TLDR: demo

Bunnyhopping or strafe jumping is a general technique in (some) games that let you move faster than the base movement speed. Originally found in quake, because of an unintended bug (it's a feature damn it) in the game's movement code. Many other games like half life, counter strike, quake 2 and 3 and more recent games like valorant, apex legends, Doom 2016 and Eternal, titanfall still have it in one form or another. Some developers choose to embrace it while others try to get rid of it, either way it is a very interesting technique and is worth understanding how it works.

From my experience playing those games and browsing the internet this is what i've learnt. Here is the demo that implements the quake style bunnyhopping. Try beating my top speed of 42.9 m/s.

The Bu ... I mean Feature

The piece of code responsible for this is the accelerate function that takes in arguments:

  1. velocity (the current velocity)
  2. move_direction (intended direction of movement, also called wishdir in the original Quake source)
  3. speed_max (the supposedly maximum speed achieveable)
  4. accel_max (the maximum acceleration)
  5. delta (the time delta between previous frame and current frame)

func accelerate(velocity: Vector3, move_direction: Vector3, speed_max: float, accel_max: float, delta: float) -> Vector3:
	var projection = velocity.dot(move_direction)
	var add_speed := clamp(speed_max - projection, 0.0, accel_max * delta)
	velocity += add_speed * move_direction
	return velocity

The amount of speed added each frame depends on the difference between speed_max and the projection of velocity on move_direction. Bunnyhopping involves having a significant non-zero component of move_direction along velocity but also maximizing speed_max - projection. This balancing act of 2 variables is what makes bunnyhopping require a lot of skill to do well. As your velocity changes this balance also shifts. A really good explanation can be found on Adrian's blog which goes through more of the mathematics and Matt's ramblings youtube video that shows off this balancing act way better than i could ever explain.

Demo Image Projection of velocity (red arrow) on the movement_direction (green arrow) References: adrian's blog, Matt's ramblings