Throttling and anti-shake in Unreal Engine

I recently studied Unreal Engine (UE), intending to transform from web development to game development. In the future, we will release a summary of experience related to game development from time to time, from the simplest to the deeper.


There are three main parts of UE learning: GUI operation, blueprint, and C++. Although for a layperson, you can do UE development without learning C++, students majoring in computer can master the UE engine in the shortest time, because the GUI of the UE editor and the blueprint of the visualization language contain a lot of "software philosophy", it seems Every design exudes a sense of intimacy, which makes it clear at a glance. Just as the design concept of WeChat GUI is to make people "use it without teaching", the GUI of UE editor also permeates the tacit understanding and habits of many industry designs, and the blueprint is essentially graphical C++.

Not much nonsense, there are 2 functions related to the timer thread in the Blueprint API: Delay and Retriggerable Delay. After research, they are throttle delay and anti-shake delay.

Delay: Throttling

https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/FlowControl/Delay/index.html

Delay function is a timer with its own throttling property. On the surface, it allows you to "sleep" for a period of time before executing the next function. It also silently throttles the input. The document says: During timing Calls again will be ignored, that is, set a limit on the number of function calls per unit time. Let's do an experiment:

Let's look at this thread: when you press the space bar, it prints "Hello", then sleeps for 1 second, and then prints "Hello World". After the game starts, press the space crazily, the console becomes like this:

It can be seen that as many "Hello" are printed as many spaces are pressed, but at most one "Hello World" is printed within 1 second, because the Delay method has throttled.

Retriggerable Delay: Anti-shake

https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/FlowControl/RetriggerableDelay/index.html

The Retriggerable Delay method is literally a "retriggerable" delay. The document says that if it is triggered again during the timing, the timer will be reset (cleared), and the timing will be restarted until there is no trigger within the specified time. Isn't this debounce, so let's do another experiment:

Still madly press the space, and then stop, the console output is as follows:

It can be seen that only the last time "Hello World" is output, which means that only the last space completes the Retriggerable Delay, which is anti-shake.

to sum up:

Learning the Unreal Engine API is a long process, and how to remember quickly determines the efficiency of learning. The human brain has the ability to remember, but it is difficult to call this function. Whether you can call it depends on whether you can successfully "convince" your own brain and make your brain believe that certain information is meaningful and worth storing. Then the brain This information will be "recorded in seconds".

Establishing knowledge point association is an excellent way to prove meaning to the brain. In this article, even if you don’t mention the concept of anti-shake and throttling, I believe you can understand the meaning of Delay, but it links Delay with known knowledge points. You can remember it instantly.

 

Guess you like

Origin blog.csdn.net/github_38885296/article/details/108525790