I have a quick question about Timer by Function. Basically I have a top down character and when my character is attacking I want him to be rotated towards wherever my cursor is on the screen. I have this set up fine at the moment by having a Timer By Function with the function running the script every 0.01 seconds to change the character’s rotation towards the cursor.
Now in previous experience the Timer by Function/Event tends to act a little funny below 0.2 seconds once compiled (works fine in editor). So my question is, what would be a better way to have this script running? It needs to be essentially every frame, but I am very reluctant to use an event tick on something that only needs to be called during specific moments.
How costly is this?
For example, if I had multiple gates like this to do responsive mechanics when called for, would it effect performance much, even if most of them were closed at any given time?
It is not costly and it will not affect performance. There’s nothing wrong with Tick. You see folks demonise its use, and rightly so but it relates to using it when not necessary.
if you need for something to happen once, do not put in tick
if you need to cast during tick, see if you get away with an event-based cast and use a direct reference or another form of blueprint communications
if you need something to happen in x amount of time, use a Timeline instead of Tick
You can use a switch instead of a gate if you need several paths of execution; you can switch on enumerators, indexes, even strings. In this case, only one output will be active:
Yup, cascading branches and so on. You can also disable tick or slow it down - Tick Interval in the class defaults.
There are many ways of handling flow control.
You can add/remove components to/from actors, those components can have their own tick and methods. You can have a component that causes the character to bleed (it will tick once per second handle all blood related mechanics and visuals).
A component like this can be given to anything that can bleed from now. A chunk of reusable behaviour with its own tick so you do not muddle the main actor.
Oh wow thanks for the information, you’ve been really helpful. Next time I have unreal open I will definitely have a look into these other tick methods.