Distance Float Reset When I'm In the Main Menu

I have a float variable which moves to my HUD widget. It’s the distance I travel but I want to to reset to zero when I am in the main menu. What do I do?

Game Instance


HUD Widget Text

The Widget In-Game
image

First of all, is there a reason for you to push the data into the GI and then have the player pull it from there AND then have the widget pull it out of the player every frame by updating the Game Instance, again every frame?

Sounds super-duper over-engineered but you may have a good reason, just asking. :innocent: My bet is that you’re attempting to have values persist between map loads. Is that correct?


I want to to reset to zero when I am in the main menu. What do I do?

Set both variables to 0.


Or, perhaps, you could briefly explain what the end goal is. Almost certain there’s a more organised way to do it all.

1 Like

The main reason it’s like this is because I have many levels the player travels through and stack up all the way to the end of the game. For now I just have it where I want it to reset at the main menu level.

Do you have any suggestions?

As above, set both vars to 0.

The main reason it’s like this is because I have many levels the player travels through and stack up all the way to the end of the game.

I’d just keep in the GI, there’s no reason to keep the player involved in this since they get destroyed anyway, right?

I’m looking for a way to set the “distance traveled” to zero if in this “main menu” level. This may clear things up a bit.

Just how to I get a boolean in the level BP of “level.menu” referenced into the Game Instance?