Ue4 line trace shotgun?

Is there a way to do this?

Hey there!

I just finished building this exact feature in my super comprehensive Gun class system. I stumbled across your post while looking up how to do it myself. Ended up having to design one.

(I may release my gun system on the Marketplace once it’s more polished.)

Anyway, I have the solution.

It’s pretty straightforward once you know what to do. I’ll give you my blueprint method, and I’m sure you can figure out where to hook it in if you’re dabbling in making guns fire already.

See attached image. Hope that helps!

Addendum: If you are not using a separate gun class (if you’re doing this right on the player character) then you don’t need to use a Cast To node for your character to get his camera, world location, etc. It should just be available under Context Sensitive in that case.

This works really well, but I am having an issue with a spawn emitter erroneously being created. Maybe it’s because I used a line trace for objects, but any time I fired, a spawn emitter was created at either the previous hit location or a random default location.

To keep this from happening, I used an Is Valid check using the Hit Actor pin from the Break Hit Result info. Hopefully if anyone else comes across this and has the same issue, this might help.

Here is a way I found useful. The “Projectile Spawn Loc 2 Right” is just an Arrow component so I know where to start the trace (at the end of the barrel of my weapon).

You could add a variable called “SpreadAmount” and then drag that to the Min and Max pins of the Random Float in Range, just do Min * -1 to get the negative range.

Thanks so much for this!