Developer knowledge network · moderated exchange

UnreliableCode コミュニティ

開発者リサーチ、リバース エンジニアリング、コーディング コミュニティ

Release

Dynamic Weapon Crosshair HUD with Real-Time Bullet Spread Circle in ImGui [v2.4 Technical Discussion]

imgui_artisan
UI Designer
MEMBER
担当者: 202
参加日: Apr 2019
投稿: 54
ありがとう: 28
3 週間前 · Aug 2, 2026 5:59 AM
#1

A responsive dynamic crosshair widget for GTA V:

CPP
void DrawDynamicCrosshair(Vector2 screenCenter, float spreadRadius, ImU32 color) {
    ImDrawList* dl = ImGui::GetBackgroundDrawList();
    float gap = max(4.0f, spreadRadius * 20.0f); // Expands as spread increases
    float len = 8.0f;
    
    // Top, Bottom, Left, Right crosshair lines
    dl->AddLine(ImVec2(screenCenter.x, screenCenter.y - gap), ImVec2(screenCenter.x, screenCenter.y - gap - len), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x, screenCenter.y + gap), ImVec2(screenCenter.x, screenCenter.y + gap + len), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x - gap, screenCenter.y), ImVec2(screenCenter.x - gap - len, screenCenter.y), color, 2.0f);
    dl->AddLine(ImVec2(screenCenter.x + gap, screenCenter.y), ImVec2(screenCenter.x + gap + len, screenCenter.y), color, 2.0f);
}
fivem_native_coder
Lua Scripter
MEMBER
担当者: 64
参加日: Jun 2019
投稿: 20
ありがとう: 48
3 週間前 · Aug 2, 2026 11:29 AM
#2

The crosshair dynamically expands when running or firing and snaps tight when standing still. Beautiful HUD design.

matrix_math_guy
Math Specialist
MEMBER
担当者: 105
参加日: Aug 2018
投稿: 52
ありがとう: 41
3 週間前 · Aug 2, 2026 5:09 PM
#3

Clean ImGui rendering.