I’m learning Unreal Engine 5 by following along with tutorials on youtube. I implemented the day night cycle from this video into my project without any problems. I then went and copied this game time and calendar HUD from this video into my project and everything worked fine until later on in the video series where the HUD is meant to interact with the interface and then the game state (here)
The problem that I have is that the “Event Update Game Speed” in my version isn’t firing and updating my “Amount to tick a second”.
Here is a screenshot of the code from the video in my gamestate blueprint:
What the desired outcome is that when I press the pause button it sets the multiplier value to 0 and then fires an event within the gamestate blueprint which updates the speed multiplier within the gamestate blueprint to 0. It then multiplies the “amount of tick a second” by 0 causing it to no longer add any seconds per tick causing the game time to be paused.
Instead what happens is that I press the pause button and it updates the HUD bar indicating that the button has worked and has set the Speed Multiplier Local to 0 but the Event Update Game Speed within the GameState never fires so it never updates the “Speed Multiplier” and therefore the “Amount To Tick A Second” to 0.
I would appreciate any help and information about why this isn’t working. I’ve tried to give all the information that would be required but I’m still learning and I could just be missing something simple.
As a note and I am not sure if this is important but the Left Mouse Button event within my Gamestate also doesn’t trigger when the left mouse button is pressed. I ave no intention of using the left mouse button event but did it as a test and notices that it also isn’t firing. The Event Beginplay within the gamestate does fire and so does my time-passing event.
If I put a print after the Update Game Speed it is being called but the print after the Event update game speed isn’t.
I thought I got close to finding the problem last night when I created a Left Mouse Button input within my player controller to execute the same “Update Game Speed (message)” but from the player controller instead of the HUD. It would trigger the event within the GameState but because the Speed Multiplier was not being set up it would functionally do nothing as it just stayed at 1. So I found out that the event is being triggered “UpdateGameSpeed” is called from my player controller but not from my HUD (I would want it to happen from my HUD so that my updated “speedmultiplier” float would be sent to my gamestate.)
After that I went through all my blueprints and triple checked that they are all blueprints have implemented the interfaces. Here are screenshots of each blueprint with the window open indicting that they are reading off the Game Time IF and edited to answer your question in case I am somehow interpreting this information incorrectly.
As an index to what my blueprints are called:
GameStateBase: BP_Customgamestate
HUD: GameTime_HUD
Interface: GameTimeIF
the Gamestate is where I’m storing time passing so that does work. The event begin play happens which starts the timer you see in the screenshots. Here is the Timeupdate custom event successfully going off:
The Left Mouse Button event does not go off though.
Could you explain what game state variable do you mean?
I was getting no errors, that’s what was making me pull out my hair that it wasn’t working. Not sure when I added the Gamestateref variable but that is what the person in the video does here.