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:
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:
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)?