Making the day go when i sleep

I’ve just started with Unreal some weeks ago, and i am making a game. I have added an go to sleep function, i’ve made everything work with it, without that i can’t make so that when i wake up it’s another time. For example, if i get to sleep in the morning, i wake up in the evening. I use the night/day cycle. Sorry for my bad english.

Could you share you Go to Sleep function? And give us some detail about how your Day Night Cycle works?

Hey there @Fullmane1! Welcome to the community! So as Sly mentioned, we would need to know more about your Day/Night cycle system. Are you just rotating a directional light with the standard sky? If so, all you would have to do is set the rotation to the same it would be when it’s regularly that time. Though if you’re using another plugin, you may have a method of just setting the time directly.

Here’s everything for the sleep function. First you get the question if you really wan’t to sleep and then you heal and get stamina

And here is the code of the yes/no buttons.

And here’s the night cycle.

I have replied with the code. Sorry it took so long time

Head into the viewport, rotate your directional light to where you consider day be started, take that Y rotation and copy it. Then make a new event just like your Change to night event, return to this and replace the AddWorldRotation node with a SetWorldRotation node and plug in the Y. This will set the rotation so it’s exactly where you set it to be.

image

1 Like

There’s just one problem. I can’t get the ChangeNight event into the ThirdPersonCharacter Blueprint where the rest of the code is. But thanks for the help on the night part

Thank you for the edditional details.
To complement what SupportiveEntity said:
SetActorLocation allows you to set a specific time with the method previsouly explained
AddActorWorldLocation allows you to jump a fixed delta in your cycle, 360 is a full cycle (a full rotation), so 180° would be half a day, 90° would be quarter of a day, and assuming your day have 24h then one hour would be 360/24=15°

Now about referencing the event:
The complication you’re facing is that you’re are doing you day/night cycle in the level blueprint, which is hard to access from the character or the controller blueprint.
I would advise putting your light and your Day/Night cycle logic inside a specific actor blueprint, and getting a reference to this actor through the GetActorOfClass node.

If you need for some reason to keep it in the level blueprint, then you should look at event dispatcher which seems the closest solution to what you have in order to call an event inside the level blueprint from your character/controller, but it seems a bit more complicated for not much of a benefit.

2 Likes