Download

Day Night Cycle w/ an Event

I’m trying to do a day night cycle that only moves when the W is pressed so it moves when my character moves does anyone have any ideas on how to go about this? At the moment when its released it just keeps going

This W only happens once. The W in your character is happening every frame.

If this is the correct event ( Time Cycle ), putting it in the forward movement of your character is the way to go.

1 Like

for something running every frame like that i like to do either a branch or a gate.

when released it closes the gate or changes the bool variable to false which changes the flow of the branch.

For this case he will have to use a branch with the axis value if > 0 to tell the other actor to move.

1 Like

I’m actually confused by this. According to the above statement it seems that the event is (still?) running after the Released. Perhaps it’s just phrasing…

How would I call the event in the level blueprint into the character blueprint? Or would I just need to copy all the Time Cycle event into the character blueprint?

Like i press W and when I’m stop pressing W the sun keeps moving but i only want it to move when the character is moving

Like @pezzott1 says, you have to check if the axis float is non zero.

With Event Dispatchers. It would be from character to level BP.

Personally I would have all the logic in an actor, not in the level BP.

I’m so sorry where would I find that?

I was just following a tutorial and that’s what they did should i create an actor and copy that in?

Well… and this is my personal recommendation: first get working what you already have. Then you can consider moving / fixing / revising. Also both @ClockworkOcean and @Everynone made you observations and are willing to help, you should listen to them. :upside_down_face:

I’d just do this:

Or even just this with no additional event:

image

ok so i’ve tried the event dispatchers and i’m not sure I’ve done it right. I did originally have the event dispatcher called where @ClockworkOcean pointed to in their screen shot but i put it the other why to see what would happen as the character is no longer moving when i press W and the sun now moves too fast around the sky and still moves when W is not being pressed


Thanks i’ll give this a try now

So hold on. The timeline is in the Level and the Input is where, in the player character blueprint, right? In which case, I’d in the character BP:

image

And in the level:


Also, if you’re planning on having more than single level, consider moving the script from the LB to an actor. Otherwise you’ll need to copy past / redo it for every level.

Sorry, I did not read the whole thread. It might have been mentioned already. :blush:

Everything for the day night cycle is in the level blueprint I think i essentially just followed this tutorial

For the code that you showed the lighting changed but the sun stayed still as did the player character

That’s because you put W in the Level. Input belongs in the player. The LB consumes it and it’s generally not a good idea to handle input in actors other than the Pawn & Player Controller.


This now got more complicated because now we see that you’re using Axis Input. This would need to be redone differently. Hold on.


For Axis event with no Timeline:

  • player running

  • level BP:


Combining Axis Event firing every frame with a Timeline that works quite differently is awkward. But if you must use a Timeline, do tell. The tut assumes you will not be doing anything to the Timeline during Tick update, that’s why combining Axis + TL would be somewhat tricky, but doable.


But if you must use a Timeline, do tell.

You’d need to spaghetti it:

  • player:

  • level

Good luck!

I’ve tried doing the top part so far without the timeline and it’s not letting me move forward only back and it’s just printing number rather than the sun and light changing

I’m going to try it with the timeline now although i’m not sure how to do it to include the add movement input

Compare with mine, it’s an incorrect node:

image

Or place input before the Branch. I’ve assumed your input spits out 1.

image

and it’s just printing number rather than the sun and light changing

Well, this is where you’d hook up the rest of your script, replace the Print with what’s needed (as in the comment above the Print String node). It will give you a wrapping value, should it exceed 24 (as in hours), it’ll go back to 0. Or change the modulo to 1 and use Lerp.