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 piece of code responsible for this is the accelerate function that takes in arguments:
velocity
(the current velocity)move_direction
(intended direction of movement, also called wishdir in the original Quake source)speed_max
(the supposedly maximum speed achieveable)accel_max
(the maximum acceleration)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.