Developer knowledge network ยท moderated exchange

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Knowledge indexLive
4Categories
919Threads
2.8KPosts
Tutorial

Bunnyhop & Sub-Tick Jump Timing Math using m_fFlags & m_vecVelocity in CS2 [v2.4 Technical Discussion]

ptr_arithmetic
C++ Wizard
MEMBER
Rep: 162
Join Date: May 2018
Posts: 73
Thanks: 42
1 months ago ยท Jul 15, 2026 9:35 AM
#1

Why simple spacebar spam fails in CS2 sub-tick:

CS2 samples movement flags at sub-tick precision. If you jump on the wrong sub-tick slice, the ground friction (sv_friction 5.2) decelerates the pawn instantly.

Optimal Jump Logic:

CPP
void AutoBunnyhop(CUserCmd* pCmd, C_CSPlayerPawn* pLocal) {
    uint32_t flags = pLocal->m_fFlags();
    Vector3 vel = pLocal->m_vecVelocity();
    float horizontalSpeed = sqrt(vel.x * vel.x + vel.y * vel.y);
    
    // FL_ONGROUND is bit 0 (0x1)
    bool bOnGround = (flags & (1 << 0)) != 0;
    if (bOnGround && pCmd->buttons.has_flag(IN_JUMP)) {
        pCmd->buttons.set_flag(IN_JUMP);
    } else {
        pCmd->buttons.unset_flag(IN_JUMP);
    }
}
netvar_ninja
Schema Master
MEMBER
Rep: 145
Join Date: Nov 2018
Posts: 16
Thanks: 89
1 months ago ยท Jul 15, 2026 2:51 PM
#2

In sub-tick you can also calculate optimal air-strafing angles (deltaYaw = atan2(30.0f, speed)) to gain +20 u/s per jump.

vtable_slayer
Senior Reverser
MEMBER
Rep: 215
Join Date: Mar 2018
Posts: 86
Thanks: 61
1 months ago ยท Jul 16, 2026 8:25 AM
#3

Smooth BHOP movement without velocity drops.