Toggle Linetrace

I currently have a line trace setup with a particle system attached to it. I have a BP for a switch that will turn the particle on and off. However, the line trace only turns on and remains in that state. How can I get the line trace to also turn on and off with the particle.

The screenshot below just shows a quick view of how I attempted to toggle the line trace. The boolean “is active” is a boolean that is attached to my laser BP, which has multiple functions for handling the particle and line tracing. It is referenced in my Switch BP and properly toggles on and off when the player is in the switches trigger box and presses “E”. So I thought attaching that same boolean to a branch before my line trace would work, but it didn’t. Any help would be appreciated.

If you’re switching that bool state in another blueprint and you just created a bool with thesame name in this blueprint then that is not going to work, they would be considered two different bools. You will need to get a reference to your linetrace blueprint from yourswitchand access that is active bool to change its state.

Oh no, that’s the same bool. Sorry for not making that clear, I will edit that in the original post. That screenshot is from a function in the lasers BP, which handles the line tracing. There is a different function that sets it to active and emits the particle.

Your debug type is set to Persistent. I think that makes the debug line show forever. Is that the problem youre having?

Could you post screenshots of more of your blueprint setup? It’s a bit hard to understand what might be going wrong with only that first screnshot

No, I just did that so I could see if the line was being drawn and would toggle off, I forgot to change it back. I need that line trace to turn on and off. I took some screenshots to try and explain it a little.

So when I hit play, there is no line trace or beam. That small cube is my (temporary) switch, so when the player is in the trigger box and press E. The beam will emit, along with the line trace. Once it hits the cube that has no color, it will light up the cube and also light up the small sphere next to it.

This is how it looks once the beam and line trace are on. The beam stops emitting like it should once it hits an object and the line trace continues like it should as well. The other cube is now turned on and so is the sphere (I just took the screenshot too early and didn’t capture it while on, because it flashes)

This screenshot is where the problem is, as you see the beam is gone because the player pressed “E” again to turn it off. However, the line trace did not turn off, which means the other cube and sphere are still turned on (once again took the screenshot too early, so now the cube is off lol). I need the line trace to also turn off along with the beam.

I actually didn’t think to try printing the hit actor. Turns out it was not hitting anything. The reason the cube and sphere were staying on was because of a BP interface I had setup and forgot to call. I finally got the issue resolved. Thank you all!

Can’t figure out how to mark this as answered lol

I set the target to the same point where the start is when it’s inactive. So the trace length becomes zero.

Just to clarify, are you sure the line trace is still firing? Because with debug set to persistant it will show that red debug line forever, even if the trace is not running. And if you are setting that bool to false there would be no way that line trace is firing. It looks like you are just seeing the result of the debug line. Have you tested to see if the bool is ever going false by printing its value? And have you tested if the trace is actually running by printing the actor it is hitting? Because it may not be the line trace not turning off that’s the issue.

To test you could also switch the trace debug from persistent to duration.

No problem, to the left of the comment is up and down arrows and undernether that is a check box to mark an answer as correct.