Line trace for visibility, hit actor, check if overlapping, then action.

I have in my game some dynamite and a dynamite box. I would like to send a line trace from the dynamite box to the dynamite to check if it is in range.

I have been using sphere overlaps to detect overlapping, but this also causes it to work through walls, which I don’t want to happen.

I have two options but I don’t know how to implement them properly.

1.) Somehow limit the length of the line trace. It would still need to be heading towards the actors in question.

2.) Line trace, then add hit actors to an array, then check to see if hey are also overlapping. Then make those hit + overlapping actors perform the function.

I have managed to send out multiple line traces with a for each loop and confirmed they are hitting things.

I suppose what I’m asking is, if there is a way, to add all the dynamite that was hit by the line trace, into an array and then I can check if they are overlapping.

Thanks for any help in advance.

You could use collision channels to have the line trace blocked.


Do note the functionality you might be after is already built into the damage system:

If I wanted to throw a stick of dynamite and have it hit stuff that’s not behind cover, I’d use that :point_up_2: However, there’s also this bit:

if there is a way, to add all the dynamite that was hit by the line trace, into an array and then I can check if they are overlapping.

Perhaps you could elaborate what we’re really doing? Ignore the technicalities, what’s the gameplay scenario like? What’s really happening to all that :firecracker: :firecracker: :firecracker: ?

1 Like

Thanks for the reply, I will look into radial damage with falloff to see if I can get it to work.

The idea is, if the dynamite or dynamite box explodes, it will explode the other dynamite or dynamite boxes.

The main problem I’m facing it that the explosions are going through walls. I only want them to explode if they are visible and in range.

Yeah, that should be pretty trivial to setup. The damage interface is already there, take advantage of it. You, kind of, don’t really need to script much to make it work. More on collision:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.