Heat and Spread System


Guns are using heat and spread system - which is used in Lyra Epic Games project example.

Idea of this system is to setup gun accuracy based on different params such as

  • spamming shooting
  • movement speed of owner
  • is owner zooming / aiming
  • is owner crouching etc.

Heat is gun parameter that is added after each gun fire, and decreases over time on stop firing.
Then gun heat is transformed into gun spread which translates into the accuracy of the gun.
It means that we can setup gun that will be less accurate when we spam firing.

In example above on left side when spamming firing rifle becomes less accurate while on the right on firing with stops makes it more accurate.

Gun heat can be changed through CombatComponent with these functions

Heat and spread can be twaeked per gun in F_GunWeaponData.


Pistol Gun Example

To better understand how heat and spreat can be setup, lets look at Pistol gun settings.

There we are only instresed in selected params as these are responsible for heat and spread.

  • SpreadExponent - Spread exponent, affects how tightly shots will cluster around the center line when the weapon has spread (non-perfect accuracy).
    Higher values will cause shots to be closer to the center (default is 1.0 which means uniformly within the spread range)
  • HeatToSpreadCurve - A curve that maps the heat to the spread angle.
    The X range of this curve typically sets the min/max heat range of the weapon.
    The Y range of this curve is used to define the min and maximum spread angle

    For pistol based on curve points, minumum spread ( when not shooting at all ) will be 2.5 and maximum 10.
  • HeatToHeatPerShotCurve - A curve that maps the current heat to the amount a single shot will further 'heat up'.
    This is typically a flat curve with a single data point indicating how much heat a shot adds, but can be other shapes to do things like punish overheating by adding progressively more heat.

    Pistol has only 1 point in curve, it means that each shot will add 12 heat even if we just started shooting ( heat was 0 ).

    You can notice how crosshair extends to max value after single shot.
  • HeatToCooldownPerSecond - How fast heat wears off per second
  • HeatRecoveryCooldownDelay - Time since firing before spread cooldown recovery begins (in seconds)
  • AllowFirstShotAccuracy - Should gun spread be ignored when heat is at minumum?
  • MoveSpeedToSpreadCurve - How movement speed of gun owner should affect spread angle.
    X axis is speed, Y is spread angle

    Based on this curve, when owner will stand still then won't get any spread
    When walking ( speed below 200 ) will get only 3 spread.
    but when running or sprinting ( speed above 250 ) will get 8 spread.

    You can notice crosshair radius increasing when character starts moving.
  • ZoomSpreadMultiplier - Defines how zooming (aiming) will affect spread angle, final spread angle will be multiplied by this value
    lower the value, more accurate weapon will be
  • CrouchSpreadMultiplier - Defines how crouching will affect spread angle, final spread angle will be multiplied by this value
    lower the value, more accurate weapon will be