Announcement

Collapse
No announcement yet.

How to properly calculate shotgun spread?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to properly calculate shotgun spread?

    I'm currently using 6 bullets, and the spread is calculated using
    Code:
     FMath::VRandCone
    .

    Sometimes, bullets are too close to each other and, the target is receiving 3 or more bullets from far distance.

    So, the questions are

    1- Is it possible to make FMath::VRandCone respect a distance between each random value?

    2- If not, how do we create a fixed spread?

    #2
    Random is random. You can get all 6 shots on the same point in theory. If you want it to respect distances between shots, you have to throw away values that are too close to already existing shots.

    For a fixed spread, you would just use sin/cos to build your shot points.

    You should look at Unreal Tournaments Flak canon code as that's essentially the same thing as a shotgun.
    Able Ability System - A high performance, robust ability system for UE4. Now Available!

    Comment


      #3
      Originally posted by ExtraLifeMatt View Post
      Random is random. You can get all 6 shots on the same point in theory. If you want it to respect distances between shots, you have to throw away values that are too close to already existing shots.

      For a fixed spread, you would just use sin/cos to build your shot points.

      You should look at Unreal Tournaments Flak canon code as that's essentially the same thing as a shotgun.
      I've implemented a function to make the spread "semi-fixed" random, dividing the spherical coordinates to multiple sections.

      By doing this, bullets are not close to each other, respecting the distance between bullets.

      Comment


        #4
        6 concentric rings. Each bullet has a Min & Max dist from center, and a random 360. Less random, more control.

        Comment


          #5
          Shooter game has some spread code in it.

          Comment

          Working...
          X