Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
TimeOfDayHandler contains a delegate that takes two parameters, hence the use of the TwoParams variant of the macro. Our class contains variables to store hours, minutes, and seconds, as well as TimeScale, which is an acceleration factor that's used to speed up time for testing purposes. Inside the handler's Tick function, we accumulate elapsed seconds based on the time elapsed since the last frame. We check if the elapsed seconds have gone over 60. If so, we subtract 60, and increment Minutes. The same happens with Minutes: if they go over 60, we subtract 60, and increment Hours. If Minutes or Hours was updated, we broadcast our delegate to let any object that has subscribed to the delegate know that the time has changed. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access