Is there a way to change game mode from blueprint

So I am trying to change my game mode from a trigger in the blueprint so I can have it trigger a different HUD. I need it to go from a game menu to a points HUD and need it to change game modes since you can’t have multiple HUDs in one game mode. If there is a way that I would be able to do that without having to switch game modes that would be awesome but if someone could tell me how to switch game modes from the blueprint that would be awesome as well.
Thanks in advance.

A good question. Some random musings below:

I would probably try to handle this by using a switch in the HUD class, so that the drawing of the interface branches out in a few different directions immediately after the Event ReceiveDrawHUD depending on some value that would be set and stored in the PlayerController.

Let’s say that the PlayerController has a public integer variable named “HUDSelect” that can take on a value of 0 or 1 for example. Then the switch in the HUD would easily be able to check this and go one way or the other, either drawing the stuff related to your game menu HUD (if value == 0) or the stuff related to your points HUD (if value == 1).

The PlayerController is also by default responsible for deciding whether or not to show the mouse pointer and accept clicks on screen, which further speaks in favour of this setup. So, the player would hit some action key (tab maybe) to switch between modes, and at that point the PlayerController event graph can toggle the “HUDSelect” variable to the correct value and also at the same time make sure that mouse interfacing is set to match. Once the Event ReceiveDrawHUD fires, the HUD graph will know what to do.

EDIT: Or perhaps more efficiently, upon switching the mode, the PlayerController calls a public function of the HUD which sets a mode value in the HUD BP directly, which is then used in the switch construct. That way the HUD doesn’t have to poll the PlayerController all the time… yeah, probably better…

Continuing from my comment above, I’m pretty sure it’s a good solution to have the HUD switch itself based on messages from the player controller. Did some quick tests, and it’s all very clean (and actually works as well) so it has to be good :slight_smile:

Like this:

So, you don’t necessarily change the game mode - you can just change what the HUD is doing.

Thanks so much for the answer this is awesome! I will try it out now and see if I can get it working. Thanks again.

Short explanation: Can’t get live feed event for text in HUD function
Wrote all this first.
So I managed to get everything working, thank you very much. I have one more question though. For one of my HUDs I’m trying to get scoring working (used to be an event that was associated with a variable that would +1 every time a trigger box was hit) but I cannot add an event in the function part of the HUD. Is there a way I could do that? I’ll post a couple pictures because I have a feeling my words did not explain it very well.

What I am trying to do

What it looked like when that aspect worked in event

For this you could use a local variable, say score, inside the HUD blueprint. When you want to update the score from whichever blueprint, get a cast to HUD and set the value that way.

You are a GENIUS ! G-E-N-I-U-S!

Tks alot! You bring me back HOURS of work :smiley:

Well done !