Why do my shotgun shells spread further as I go further?

Hello Community! I have made a shotgun system where it fires 11 shotgun shells. I have made it using this code.

It works fine it’s just that the further I go, the wider the spread gets. Is there any way to get the spread to always stay he same size? Thanks! Also I have a question about line tracing. Which one is better for guns. Line trace by object or line trace by channel. What are the pros and cons. Thanks!

Is it ok if you can show me an example blueprint. I understand what you mean but I am just wondering how to do the second part. Thanks!

you could use two groups of line traces the first group which shoots out from the gun and spreads, then the next group uses the end points of the first group as it’s start position. Then the end position is just the shotgun’s forward vector * range(float) + start position.

Alternatively you could just shoot a single sphere trace, but you wouldn’t be able to do partial hits very easily.

Not sure about pros and cons, I would probably just go with line trace by channel visibility until I run into a situation where that won’t work.

sure, here you go.

I was just using an arrow component as the tip of my gun, it’s useful for visualization purposes. The “projectile spawn loc 2right” in the pic of your bp is probably the scene component you will be using.

Thanks!
Your help is appreciated!

Wait where is arrow?

Hello! I did what you said but this happens: Shotgun Ue4 Issue - YouTube

that’s odd, im not sure what’s going on. in the arrow component detail pane there is check box called “hidden in game” if you uncheck it you can see what the arrow is doing as you move around.

you are adding where you need to multiply

forward vector x 1000

The arrow is staying perfectly in place.

Ok Thank you. I will try this later in the day.

I did but it still doesn’t work.

I guess you could use the forward vector from the camera like you are for the the first group of line traces.

Alright, will try later in the day

It works but It goes through certain walls. If I go too close, the line trace appears on the other side.

you’ll need a branch node after the first line trace just to check if you hit something. If the return value is false then run the second trace. If true apply damage but don’t run the second line trace.

Wouldn’t hurt to put a branch after the second line trace either, since you don’t need to execute apply damage when miss.

Alright will do

Ya that still doesn’t work. What should I do now?

if the linetrace is going through wall then check the collision settings of the walls. if the gun is going through walls you could widen the collision capsule around the player.