I know there are other shotgun line trace threads here but I couldn’t get mine to work using those methods. I can’t figure out why I’m not seeing multiple line traces, the weapon shoots but only one line trace.
I’ve tried changing the below variables too with no luck but here are the current values:
MinSpread = 10
MaxSpread = 45
BulletSpreadAmount = 6
Range = 2500
Hey @DarkEmbrace96!
Is the line trace that’s coming out in the exact middle direction? If so that might be a problem with your min/max spread.
A test for amount of traces, put a PrintString after the ForEach loop running into the rest, and for the string plug in your Index integer from the ForEach! It should print all of your shots. If it only prints 1… Then we know it’s not the spread min/max. 
instead of BreakVector or Make Vector (when you have nothing plugged in) you can right click and select “Split Struct Pin” and you will get the same effect in less space
are you sure that it is only happening once? place a Print String coming right off the loop body, and print the index does it spit out more then 1 number?
deviating all the values at once by random X,Y,Z would modify the ending points. instead rotate the Direction vectors by a random angle within your spread before applying the range.
The bullet does not spawn directly in the centre but a little off so that does work, however the for loop returns 1 here, I’m not too familiar with for loops but i thought this would always return 1

a for loop runs a number of times from StartIndex to LastIndex the Blueprint For loops are inclusive so bounds checks need to be understood. (if you put in max of 5 but the body is accessing like an Array with only 4 things then you will get an out of bounds exception at number 4 because C++ Arrays are Zero for initial index)
1 Like
It should return each number in sequence. So the ForLoop isn’t looping!
Where does your code end exactly? You will want to continue the later code off of the “Completed” execution, that may be where the problem lays.
Break the “Hit” and see if there’s anything important hit. If TRUE, do damage etc. If FALSE, end, which will restart the ForLoop. You should use the line traces to gather up useful hit objects, add them to an array (which you should use “Clear” on, before the shot) then For Each on that array once the shotgun is done doing its thing, and add damage to each thing in the new array.
I actually just fixed it after an hour of pulling my hair out. I put the loop before the line trace function, for some reason it didn’t want to work in that function. Kind of annoying because now I have 2 switches but it works