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.

Hi @Rev0verDrive

Thank you for your reply! although your setup kinda works, the problem now is that the sphere trace stops growing the moment it touches the first enemy, and i want it to interact with the other ones as well. (see example)

As mentioned before, a do once node in the enemy BP seems to do what i want. But i cant find a way to properly reset it, as i want the trace to interact with the enemy again the moment i trigger it again.

I tried using a delay before resetting the Do once, but that made it react unpredictable as show in my earlier comment. I also tried using an BP interface and having it called the moment i press the button (and in return reset the do once in the enemy BP) But this way only the closest enemy (cube) will interact again when triggered with the sphere trace.

This is in the character blueprint:

this is in the enemy blueprint:

@VisAgilis

Although not exactly what i want, that setup does look interesting!

See my reply to @Rev0verDrive i want the sphere trace to continue growing after overlapping with an ememy just once (and having the enemy get called just once after the interaction). It doesnt necessarily have to be pushed away or moved around, just an initial interaction. The problem im facing now is that the interaction keeps getting fired as the sphere trace keeps growing beyond the enemy actors (spheres). I hope this makes sense!

Alright, my setup is still the same in that case as well. Here’s the result:

That does look like what im aiming for!

I’m curious how you made that setup, and if it can be extended with more enemies that are further away (providing the sphere trace reach them).

I was inspecting your setup and couldn’t figure out what might be the problem in your case :cowboy_hat_face: Because mine is practically the same! Here’s what I did inside the enemy BP:

(I had a separate BP for the bubble instead of a sphere trace that’s why I have collisions but should still be the same, I’ll also test your setup later)

are you using a growing sphere with collision to get the actor begin/ end overlap events, instead of a sphere trace? Not that it matters for the end results. i was thinking about doing something like that but i figured a sphere trace might have been easier :')

Well if it’s gonna be invisible sure! I’ll also do some debugging in your approach because:

Exactly! Very interesting.

Thank you for your replies.

I’m gonna see if i can recreate your setup and i will let you know if i run into any trouble :sweat_smile: