I have a blueprint that does a line trace from my player character camera while the “E” button is held. The hit result checks if a hit component has a “nodule” tag, if it does it will execute the rest of the function, if not it will stop there.
This works as intended but I am trying to figure out an exception, I have multiple copies of the same actor (with a component in it that has the “nodule” tag).
Some of these duplicated actors are placed right next to one another, while the line trace is active and I move my camera view back and forth between those two copies, the hit result registers that the line trace hits an actor component with the “nodule” tag, and executes the rest of the function.
I want to add a condition that stops the execution if during the line trace, it hits anything else than the initially hit actor component with the “nodule” tag, even if it’s a duplicate actor with the exact same properties.
So this looks more or less like the BP I made. I’ve recorded this quick video to give some clearer context.
1- These two sphere are duplicates.
2- I can hold “E” while looking at both of these spheres (the sphere has the tag “nodule”), you can observe the progress bar rising as my function is executing.
3-If I break line of sight while holding “E”, my function stops executing (removing the progress bar UI and reverting the progress back to 0%)
4-If I align myself so that I can move my line of sight back and forth between these two actors, since they are duplicates, my function will stay executing.
I want to be able to add a condition to my function that stops it from executing (like breaking line of sight) if my line of sight switches to another actor than the initial one. (so pretty much stops “point #4” from happening. This is a bit tricky since the spheres are exact duplicates.
It’s running on Tick (or EI Triggered) so it is continuous.
trace, see what you hit
if you hit what you need, keep using it instead of tracing
release trigger, clear the reference
4-If I align myself so that I can move my line of sight back and forth between these two actors, since they are duplicates, my function will stay executing.
I believe it’s a matter of storing a reference, if you have one already, any other hits do not matter.
I understand that, the focus though is the line trace continually assuring that it is hitting the same actor with the correct tag. In your exemple the trace stops as soon as it hits an actor with a correct tag.
trace, see what you hit
if you hit what you need, keep using it instead of tracing
This is where we deviate, my BP continually traces to make sure it is hitting an actor’s component with the “nodule” tag (as I intended), if it stops hitting it I stop the progress.
This is how my BP goes. Conditions for progress bar:
Hold E (starts continuous trace)
AND
Line trace hits an actor’s component with the “nodule” tag
Exceptions (terminates execution):
Release E (stops tracing)
During continuous line trace, Line trace out =/= actor’s component with the “nodule” tag
Desired additional exception:
If continuous line trace hits a different actor, even if it has a component with the “nodule” tag, terminate execution
I don’t think I actually made this clear earlier, hope this helps you understand
That is super helpful !
It helped me solve it, you had the right idea in your second reply, it’s just that I needed to put the hit component validate after my line trace, because of how I built it to continuously check the hit result.
Here’s how it works:
Continuous line trace by holding “E”
Checks if hit actor has “nodule” tag
Get Validate the hit actor variable
Is not valid ? Set the line trace hit actor to it
the last branch checks if I’m continuously hitting it, if I hit a different actor, even if it’s a copy, it stops
On release of “E” key OR line trace conditions failed, nullify the Hit Actor variable