Developer knowledge network · moderated exchange

UnreliableCode Topluluğu

Geliştirici Araştırması, Tersine Mühendislik ve Kodlama Topluluğu

Knowledge indexCanlı
4Categories
919Threads
2.8KGönderiler
Tutorial

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

ptr_arithmetic
C++ Wizard
MEMBER
Temsilci: 162
Katılım Tarihi: May 2018
Gönderiler: 73
Teşekkürler: 42
1 ay önce · 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
Temsilci: 145
Katılım Tarihi: Nov 2018
Gönderiler: 16
Teşekkürler: 89
1 ay önce · 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
Temsilci: 215
Katılım Tarihi: Mar 2018
Gönderiler: 86
Teşekkürler: 61
1 ay önce · Jul 16, 2026 8:25 AM
#3

Smooth BHOP movement without velocity drops.