Firing Distance

I’m making a 2d run and shooter game in c#. The only problem I face is the firing distance. For example if you have a shotgun(a close range gun), I want it to fire for only a certain distance like five feet from the player and kill whoever is in that five feet. I just want to know how you would program it? Thank you in advance!!!
11041-distance.jpg

The yellow line is the distance. The blue is where it starts and the maximum(five feet) is where the bullets(gameObjects) get destroyed. Thank you for reading.

You should post your shooting script, since nobody has the slightest idea about your code. Anyway, the usual way to solve this is to cast a ray in the aiming direction with a limited range - something like this:

void Update(){
  if (Input.GetMouseButtonDown(0)){ // if left mouse button pressed...
    // cast a ray from the weapon position with a limited range
    if (Physics.Raycast(weaponPosition, shootingDirection, range)){
      // something was hit - kill it!
    }
  }
}

NOTE: The victims must have colliders in order to be detected by Raycast.