User:MoltonMontro/sandbox

From SDG Wiki
Jump to navigation Jump to search
Alt text
Axe Pick 1198 TrophyAward Bronze 276.png

Useful pages that need love...


Steam Economy project ("M" is for "Maps")...

Steam Economy project ("B" is for "Bundles")...


Breakdown of ballistics

Advanced ballistics has more to do with the UseableGun class than the ItemGunAsset class. I'm primarily working on documenting how properties for asset classes work, as opposed to how these are actually implemented by useables, buildables, or constructables. But, here's a general rundown:

  • Ballistic_Drop is bullet drop. The lower the value, the slower the bullet drops per iteration. Setting it to 0 would remove bullet drop entirely—the Shadowstalker railguns have no bullet drop.
  • Ballistic_Steps is the bullet lifespan. The lower the value, the shorter the lifespan.
  • Ballistic_Travel is the "travel time". The lower the value, the shorter the bullet travels per iteration.

There is no single formula that could be given to accurately describe how they work together. They're perhaps best represented as their individual values. There are relevant formulas for converting between Ballistic_Steps, Ballistic_Travel, and/or Range. But these are used to calculate the default values for ballistics, in the event that a value is missing. Practically, it's Ballistic_Steps * Ballistic_Travel = Range, although you do not need to specify a value for both Steps and Travel. Instead, only specify one value, and the game will calculate the other (based on Range value). If you assign both a custom Steps and a custom Travel, then they should equal the assigned Range when multiplied together – otherwise, you'll have a value mismatch (which will appear in the error logs).

Understand that when I say something occurs "per iteration", there is an if/continue loop that keeps iterating until the raycast is valid. With each iteration, two important things occur. First, the position of the bullet moves (current direction) * Ballistic_Travel. Second, bullet drop changes the Y vector of the current direction.

"Current direction" initially represents whichever direction the player was originally facing when they fired the bullet (i.e., "forward"), with randomization to the top/right based on the gun's range of spread. But this is only true for the first iteration. With each iteration, the current direction's Y vector will be decremented by the value of Ballistic_Drop.