Note: basically YTB/watch? V =9_40m38o81M&t=287s of the elder brother’s RTS tutorial moved over the original video is 720P, the author of their own implementation after parsing.

GameTimeHUD {SunBp} : a crude time HUD {SunBp} : controls the sky sphere and the sun, and realizes the day and night cycleCopy the code

I’m starting the sun is turning

GameStateBp

The core has two parts: a TICK event for switching between game time and real time, and a task dispenser.Copy the code

Time is precious

SetGameTime function

Here I multiply the game speed by delta time to get the game time per frame. NatureGameTime is the total past time in the game and returns the total past time in the game and the number of days in the gameCopy the code

SetClock

Use the total time to get the corresponding minutes and seconds to return the array to the interface that is implemented with the HUDCopy the code

SetCalender

In the original video, there was no update judgment, so we directly updated all the data in each frame and added an update judgment to prevent useless data updates. So we took the original date class and made time update, which is to add the past date of the game to a base date and put it on the interface that we implement with HUDCopy the code

BeginPlay when there’s a lot of demand

The first thing to do is get and set up the playcontrollerRef to get the GameTimeHUD laterCopy the code

The second thing I want to do is set the time of the original game to zero and the third thing I want to do is set the date of the original game to the set dateCopy the code

Otherwise, the date on the HUD will suddenly change from 0 to the date of the next hop plus the delay is a matter of figuring out that the initialization order between the HUD and GameStateBp can't be handled and then thinking about how to deal with it. The fourth thing is to set up the game speed modifier which means game speed modificationCopy the code

The Dispatcher bomb people

The mission dispatcher has the presence to send the bomb to the applicant and control the detonationCopy the code

It then appears in THE SUNBP and controls the speed of the game in the updated SUNBPCopy the code

GameStateBP review

An interface implementation for LIB_GameState blueprint communication

So in a nutshell, the GameTimeHUD interface that GameStateBp implements with GameTimeHUD later is the interface that gets the data from GameStateBpCopy the code

GameTimeHUD

All it does is display time data from GameStateBp and allow the game to speed up and slow downCopy the code

Get_YEAR

Get_SEC

In order to change the layout of the data has been adjusted blueprints change or verboseCopy the code

To speed up the time

The setting steps that communicate the slider values using the interface are flexibly adjusted according to the order in which the data is addedCopy the code

Slow down the time

The logic is the sameCopy the code

To The World!

Added a variable to restore the original game speedCopy the code

The slider modifies the time speed

Blueprints are complex features so just squeeze in thereCopy the code

SUNBp

The main control over the sky sphere and the sun is followed by the exposed variables to be linked in the world viewCopy the code

It starts with an explosion

GameStateBp has a dispather that sends missions and then he gives SUNBp a remote-controlled bomb that explodes every time the game time and speed changes causing a new event SetGameSpeed is used to indirectly set the sun's speed in SUNBpCopy the code

Solar energy rotates 360 degrees in 86,400 seconds a day

After reacquiring the game speed, I did a tick event 86400 seconds a day to calculate the ratio of solar energy to 360 degrees per second/per degree to change the offset of emitted lightCopy the code

The corresponding blueprint variable is exposedCopy the code

LIB_FUCNTION

Everything in the grocery storeCopy the code