Have my growing sphere trace only hit once?

Hi all,

i currently have a setup that allows me to grow a sphere trace after pressing a button using a timeline. The moment it hits an enemy actor i want the enemy to do something. Right now as a test, i have an ‘‘enemy’’ that changes color and snaps to a different position.

The problem i’m facing is that since the sphere trace keeps growing every frame, it also ‘‘hits’’ every frame. which in turn makes my pulse interact event get called every frame when it hits an enemy untill the sphere trace stops growing. I really only want the pulse interact event get called only once on the initial hit.

I tried using the ‘’ Do once’’ node, which sort of works, but unfortunately it only works once (as the name implies). I tried resetting the do once with a delay node at the end but that doesnt work with multiple enemies close to eachother. Maybe i can use a gate? unfortunately i’m not really familiar with how those work., or maybe a different hit result? Although blocking hit and initial overlap gave me similar results.

Hopefully someone could help me with this.

Cheers,

Or, you can handle the action after a custom event inside your enemy blueprint instead, implement a safe time for them with the Do Once node there, and call it from your player character BP.

Hope this helps! :innocent:

Hi Vis,

Thank you for your quick reply!

Apologies, i think what you are proposing is similar to the setup i already have. I should have mentioned in my original post that the sphere trace blueprint is in my character BP and the pulse interact blueprint is already inside of my enemy BP. The problem is that i dont know how to set a proper reset for the “'do once”.

using a delay at the end doesnt really work as after the delay ends while the sphere trace is still growing, the enemy thats closed gets ‘‘hit’’ again. it also shows some problems when multiple enemies are close to eachother.

I made some videos to hopefully get a better idea of the problem,

the first video shows what happens without the ‘‘Do once’’, whenever the sphere trace hits an enemy it will continue to call the event.
Continuous hits

the second video shows how i want the interaction to be, unfortunately it only happen once and i want this to happen every time i create the sphere trace.

What i want to happen

The last video shows what happens with a delay ( in the current setup)
when the delay is too long, the enemies in the back dont interact at all. if the delay is too short,
the enemies inside the trace will move again (as in this example)

Do once with delay

Hopefully this helps to visualise what i’m aiming for.

cheers,

I’ll look into this the next time I’m on my PC and test it myself.

Cheers!

Hey @beekder! Is this your objective?

Create a new custom Event. Name it STOP. Hook it up to the Timeline STOP pin.
Take the trace return value and pipe it to a Branch.
Branch True → Call Pulse Interact on the hit actor → Call STOP event.