I’ve got many things running from Event Tick in different blueprints, which is starting to take its toll on my fps. My questions is what is the best alternative to using Event Tick? Is using timers the way I should go?
One example I am using it for is adding a constant rotation to the mesh of my character if Gamepad Shoulder Right or Left is down.
I would like to be able to add a constant rotation to the character using “AddRelativeRotatoin” but it only rotates in intervals of whatever I have the rotation set to.
Alright, well I figured it out using a timeline… Timelines are set from 0-1 second with a constant variable. +3 for one direction and -3 for the other. Didn’t think about keeping the values on a timeline the same. Here is my test BP:
Because of that i created “pulse dispatcher” in game state blueprint (i recently moved it from player controller, as game state is easier to get reference to).
So basically I call that dispatcher every 0.2 second (0.25 is when you start to notice).
On event tick in game state I compare “last pulse game seconds” + “pulse delta seconds” with “game time seconds”.
If current “game time seconds” is more than last pulse plus delta i call dispatcher.
Everything that needs some timed actions hooks to that dispatcher.
I found this much less cluttering than using old fashioned timers, they are too easy to mess up.
Ps you can also edit tick frequency in every blueprint properties in details panel. So making blueprint actor component that reads some global value from place like player controller or game state, and then changes that property for blueprint could be your solution.
Why do you need so many stuff in the Tick? I have a rather big game by now and only have like 5 variables that update over time in it.
That are:
Health, Hunger, Thirst, Toxicity which change over time
The remaining time of a Timer in a CraftingSystem and the Tick is used to replicate that time to the Client
That’s all i have in my tick after like 3-4 months.
What exactly are you using it for? In MOST cases, people are actually using it for the wrong things.
And don’t want to say you actually do, but just to be sure that you don’t learn the wrong things
Well, controller inputs i feel should be attached to tick events (assuming the game is real-time). Its probably a case of inefficent handling of the code following the event dispatch.
You wanna kill the code asap if its tied to a tick event. Meaning you place all the checks to see if you wanna run that particular thread of code BEFORE any of the code actually fires. (I.e. check if a move is valid or not before going ahead and computing everything AND THEN deciding you want to do nothing after all.)
Controller Inputs, for example, should be bound to the InputComponent and will tick on there own if they are Axis.
A button press on the keyboard or controller doesn’t need the tick. They only happen once in a while.
You should only use the Tick if stuff really happens all the time. Like a healthbar regenerating itself. As soon as you can
say “This only happens once in a while” you should NOT place it in the Tick.
In addition to the events I was running in tick on my character (restoring stats-I switched over to timelines), I am also doing a lot of UMG events on tick as well (was a temp solution that I have not yet changed). So trying to reduce as much as possible. After I figured out how to use timers, it worked fine. When certain parts of my UMG were initiated, my fps would drop by 2-3 frames… Which wasn’t too big of deal at first. But then I actually left my game running with the UMG elements still displaying while I played a match on my xbox and came back and the frames were in the 20s compared to the 59fps I was getting at first.