I would like to record the number of frames from the start of an event to the end, possibilities?

I wish I was that great! lol, far from it. , it looks like the code should do what you want. A couple of points. (and the points are all just nit picky, but it’s good to train yourself to do it, without thinking about it)

  1. In the event graph, use the increment node, instead of the add node. This way you will bypass needing to do the set. Note on the increment node, that the input is a Diamond pin, meaning that it’s a reference being passed, hence the node actually is incrementing and setting the variable reference.
  2. For something like a counter, use Integers instead of floats. While processors have advanced a long way, the CPU still is faster at working with integers than it is floats.

After looking at your code, it would seem that you are actually after the period of time that the keypad button was held down, not really after the number of frames. In order to generate this in a different fashion. Just take the same accumulator (it’s already a float, and should stay a float), and add to it the Delta Seconds that is passed from the Tick call. The rest of your code should not have to change. Then when your getting the message displayed, it truely will be the amount of time the button was held down, and you will not need to bother with the “Framerate to Seconds” call etc.

In terms of having this all in a function. I was really thinking in terms of having it in another blueprint. The reason for this, is that when starting to get performance/event/counter information, it’s easy to start adding to it, and it begins to grow quickly, and then it’s all over the place in the actual product, making it more of a pain in the butt to remove later on. If it’s all contained in a external piece of code ( in this case a blueprint), only the calls to the blueprint need to be located, and removed from the product. Far less error prone.

Hope this helps,