Developer knowledge network ยท moderated exchange

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Knowledge indexLive
4Categories
919Threads
2.8KPosts
Analysis

Weapon sway and aimcone dispersion calculation in Unity engine

raycast_ryan
Ballistics Dev
MEMBER
Rep: 72
Join Date: Sep 2019
Posts: 32
Thanks: 16
1 months ago ยท 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
Rep: 35
Join Date: Apr 2019
Posts: 13
Thanks: 47
1 months ago ยท 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
Rep: 162
Join Date: May 2018
Posts: 73
Thanks: 42
1 months ago ยท Jul 13, 2026 12:31 PM
#3

Great explanation of Unity weapon spread math.