I am working on a game mechanic similar to skyrim where the player can advance time by doing different things or let the clock move on it’s own, but I don’t know how to artificially move it.
Hey @M-M2021!
It looks like the code you’re showing is only to pull what time it currently IS. Can you show the code where you’re actively setting the time? Is there a seconds/minutes/hours ticker anywhere? Or does time not flow actively?
I was going to ask the same thing did you set up a clock to actually start a Night/Day cycle in your game to actually skip
If not here is a tutorial
Game Time is largely useful for measuring player wallclock time; “real play time” (plus network dilation and maybe pausing.)
What you’re talking about is “simulated calendar time,” which sometimes advances at the same speed as game time, but sometimes doesn’t.
You need to introduce the concept of “in-game calendar time,” and have some system to manage it. Typically, GameInstance would be used for this, but for multi-player, you need to also figure out how to distribute it.
At a minimum, “in-game calendar time” is constructed by adding some “baseline time” to the current “unreal game time.” This makes them both advance at the same speed. When you store a savegame, you record the current value of in-game calendar time. When you load a game again, you read the unreal game time, and you subtract this value from the savegame calendar time, and set the basline time to that quantity, so the game resumes at the “same” simulated calendar time.
Freezing the clock when pausing requires that you have the ability to “pin” the calendar time to some other value, and then “un-pin” it (and reset the unreal/calendar relationship) when un-freezing the clock.
Jumping calendar time ahead, means adding some value to the baseline time value.
Your skydome/sunlight simulation should probably also be derived on simulated time, rather than just unreal game time. This means that you need to forward your concept of “current time” to shaders, perhaps using a shader parameter block or some other kind of global override/state.