How can I continuously find how many collisions happened in the last 2 seconds?

Hi, I currently have a system set up in my Level Blueprint to count how many times all instances of a class blueprint (Sphere) have collided with the walls in the level. That system loos like this:

The counter is triggered by the “Hit Event” in the class blueprint using an event dispatcher.

This works as I want it to. However, I want to use the variable generated by this to continuously update a float parameter within a Sound Cue. Which again is fine, with this system:

My problem is, I don’t just want the parameter to go up in a linear scale i.e. the more collisions there are the higher the parameter goes. I need it to be continuously monitored, as in constantly updated with how many collisions there were in the last few seconds, so that the parameter can change in real time along with the amount of activity within the level.

But I’m completely stuck! Any advice would be greatly appreciated.

Thanks in advance.

The easy way would be to connect a 2s delay node to your set node and just decrease the value by 1 again.

HI, thanks a lot for your response but I’m not sure how this would work. Surely that would just reduce the collision count by 1 every two seconds. What I need need is something that may work in a similar way to a Tick, but every time the tick fires it looks back two seconds from that particular frame and updates the amount of collisions that happened in the two seconds prior to the frame, thus giving a value that is updated on an ongoing frame by frame basis.

I know it’s not possible to do it that way but just trying to find a workaround that will do something similar!

Thanks again.

A delay node simply delays execution of the next node by 2 seconds. It does not repeat, unless you call it more than once.

event → add 1 → delay 2s → remove 1

That is what it does.

I notice your set node execution goes off to another node. You’ll want to put the 2s delay at the end of that chain of nodes.

The alternate, and far more complicated, method would be to have an array of times when the event occurred plus (2 seconds.) Sort of like a queue of times. When your event occurs, you queue up the current time plus 2 seconds. On tick, you dequeue the number of times which are less than the current time. The number of events in the last 2 seconds is the size of the queue.