Download

Possible to tick custom events (or "inject" them into tick)?

My never-ending quest of optimising things that shouldn’t really need optimising because they are already lightweight, I’ve stumbled into an interesting situation. I currently have the following blueprint setup:

e8dcca96ee84ff815202d279e25ef2df6c278271.png

As you see, this is a pretty standard way of doing things. Check every tick if the mouse button is held down via a proxy boolean, and if so do some stuff. The code you can see is quite lightweight, but it still seems like it should be unnecessary to poll it every single tick. I looked into using a While-loop (using the button held boolean as the condition) in the custom event, only to realise that the custom event is tick-dependant and is required to complete each tick.

This begs the question, is there a way to tie the custom event to the actor’s tick without having to poll the boolean at every tick? I.e., is there a way for the “Right Mouse Button” event to either inject it to the end of the tick, or make it possible to enable/disable ticking of the event alongside the main actors tick? Something like this mockup:

961a147a0197c9eabfb8508cfb5704f7435c0134.png

Or for that matter, is there another way to optimise this at all?

EDIT: …and then comes the moment that happens too often. Shortly after posting the post I found a third alternative that from the looks of things seems to achieve the effect I’m looking for. I guess I should add the following questions:

Would this this is a correct way of doing things? Is this theoretically better for perfomance than using the constant if-check on the boolean (the reason for saying “theoretically” would be that I presume the difference is too marginal to measure unless I find something heavier for it to do than just rotate a camera)?

141a0853277cfd89f68e9e065a8a6b3da3e0a9c6.png