Does anyone know if there’s a way to run a trace (i.e say on tick for testing purposes) but only return a single result per hit? I.e As part of a weather audio system i’m building, I’d like to scan around the player using a sphere trace by channel and if it detects any meshes with the right custom channel it spawns an audio loop at the locations of the hit which plays for the duration the player is in range.
Obviously I only want those loops to trigger once per hit location and continue looping whilst the player is in range and then stop when the player leaves. At the moment I have the trace element working and it detects what it needs to but it’s spawning instances of the the loop on tick so I’m getting a ton of audio triggering in those locations when I just need a loops to start/stop. (
What if you gave the player an overlapping sphere (with the appropriate channel) and use Begin / End overlap to start / stop playing the loop? There seems to be no need to Tick anything here.
Essentially, use the collision sphere as a sensor.
From your description it seems like it’s an issue of not identifying instances where the audio is already placed, if you’re hitting actors and that’s how you know where to place the audio then you need to add the hit actor to some array, next time check if the actor is already in the array, and when the player leaves or you destroy the audio at a certain location then remove the actor from the array.
The proper solution like @Everynone mentioned is to use some sphere and use the begin and end overlaps.
Thanks all! Yeah I will need multiple hits to be returned as there’s parts of the map which are a bit narrow and have multiple objects in range, which was why I was looking at the multi sphere trace initially. If I can’t get multiple hits from a single overlap then I was thinking I could set up a number of them around the player by adding a few sockets and that might give me the coverage I I’m looking for.