Interface event not firing

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:

This is my version of the HUD from the video tutorial:

Here is the part of the eventgraph for the HUD that triggers when the pause button is pressed in the HUD:

Here is inside the function to Set Game Speed:

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.

First things first. Can you put a print here

image

and here

image

Are they both being called when you expect?

1 Like

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

Thank you for responding!

Make sure GameStateRef variable is valid.

2 Likes

In that case, I’m assuming you are not using your gamestate.

Best to check your game mode override in the map ( or your project setting if not ).

Here is a screenshot of my GameStateRef in my HUD which I believe is valid:

Here are my world settings in my map:

Here are my project settings:

It all looks ok.

Can you get the game state to do anything?

If you print something on begin play in the game state, do you see that?

How are you making that game state variable? Something like

image

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?

How did you construct this variable?

image

Because you’re using an interface, you should just be able to say

image

That did it, thank you!

Little embarrassing that i never set the reference. I’m guessing clicking add variables and adding a reference type that way isn’t enough ?

So you must have been getting ‘none’ errors? Looks like @sp3cim4n was right…

No, it’s never enough. In the general case, the engine doesn’t know which X you mean.

You can’t just say ‘a box of eggs’, you have to say ‘THAT box of eggs’… :slight_smile:

2 Likes

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.

Thank you very much for your help.

1 Like