Developer knowledge network · moderated exchange

UnreliableCode-Community

Community für Entwicklerforschung, Reverse Engineering und Codierung

Knowledge indexLive
4Categories
919Threads
2.8KBeiträge
Analysis

Weapon sway and aimcone dispersion calculation in Unity engine

raycast_ryan
Ballistics Dev
MEMBER
Vertreter: 72
Beitrittsdatum: Sep 2019
Beiträge: 32
Danke: 16
Vor 1 Monaten · Jul 13, 2026 4:26 AM
#1

How Rust calculates bullet spread angle:

In BaseProjectile:

  • aimCone (float): Base weapon spread angle in degrees.
  • aimConePenalty (float): Accumulated spread while firing.
  • stancePenalty (float): Standing multiplier (typically 1.5x).

The game calculates final firing direction by taking camera forward vector and applying a randomized polar angle offset within aimCone radius.

Reading aimCone values in real-time allows drawing an accurate dynamic spread circle on your HUD!

recoil_god
Member
MEMBER
Vertreter: 35
Beitrittsdatum: Apr 2019
Beiträge: 13
Danke: 47
Vor 1 Monaten · Jul 13, 2026 8:24 AM
#2

Dynamic spread circle in ImGui expands when you move and contracts when you crouch. Gives perfect visual feedback on shot accuracy.

ptr_arithmetic
C++ Wizard
MEMBER
Vertreter: 162
Beitrittsdatum: May 2018
Beiträge: 73
Danke: 42
Vor 1 Monaten · Jul 13, 2026 12:31 PM
#3

Great explanation of Unity weapon spread math.