How to "SET" an exposed string variable?

Hey all.

So I’m trying to create a system that allows the player to hit a button labeled “Next” inside a widget and have it load the next level. The problem is knowing what the name of the map file is for the button to load.

My thinking was that I could simply create an actor that I add to the level with a string variable called “Next Map Name” and expose this to the editor. I then place the actor in the level, type in the name of the “next map” without the .umap extension and then pass this info back to the “Next” button.

Inside the Blueprint Actor (which is also the save slot actor) I created a string variable “Next Map Name” and then inside the UI widget I reference the actor, “Get” the Net Map Name variable and pass it to the Open Level node. I then place the actor in the map and type in “Mission02” as this is the name of the next level I want it to load. Sadly when I click on the button it doesn’t work and instead proceeds to load my default map (the main menu).
I tried to debug this by having the Next button execute a Print String node to show me what info is being passed to the Open Level node and when I try this, clicking the Next button still does nothing. No info is printed to the screen.

So this leads me to believe that I haven’t properly “Set” the Next Map Name value. I assumed that by adding the actor to the world and simply typing in the value I want into the exposed variable slot would effectively “Set” the Next Map Name value but this is obviously not the case.

So how would I got about "Set"ing the value that I’ve manually typed in?

Anyone have any ideas?

Well this attempt should work in theory and from what I understand it should work like that.

The first idea which comes to mind is that you referenced this variable improperly in the level and don’t have any actor at all inside the variable you try to get the level name from inside your widget.

Also I personally would place this variable inside of the game state or game mode and set that variable in your level blueprint on begin play.

This would remove the unnecessary actor and remove potential mistakes with getting this actor. And it would also make it easier to find the point where you set this value since in a busy level it will take a few seconds to find it.

If you want a more specific answer you should post a picture of your bps since that way it’d be easier to spot errors.

Cheers,

Erasio

Sorry, you’re right I should post pictures. I was just in a hurry the first time I posted. The reason I made an actor was because I was following the suggestion of Epic’s Time attack tutorial - YouTube

Essentially the reason the designer suggests to use an actor instead of a level blueprint is because it makes things easier for future updates without having to go through and making major adjustments to the level blueprint.

So inside the SaveGameActor I’ve also created the variable for the NextMapName:

Then inside my WinMenu widget I’ve set it up so that the Next Map button triggers an open level node with the NextMapName linked in:
(Large image url - http://torquemod.com/WinMenuWidget.jpg)

Do you set your reference savegame actor somewhere?

Like in event construct or so?

I mean yes it’s exposed but do you create it in the level BP and directly reference the actor or how do you do it?

To test if I’m right just use “get all actors from class” select your level reference and get item 0 from the resulting array. Replace your variable in your widget with the result.

If I’m right it will work set up like that.

Sorry I’m still really new to blueprint and all of that just sounds like Greek to me. I’ve created the variable inside the Actor blueprint. Then I drag that actor into the world and type in the name “Mission02” Then inside my WinMenu widget I reference the actor and call the variable. I have not added the actor to the level blueprint at all or anywhere else. I figured simply placing the actor in the world and manually typing in the name I want would be SETing it. I don’t know how to SET the name if its something that will change with every level.
I suppose I could skip the actor and just Set the variable in the level’s blueprint but I wanted the actor to work cause its easier. The weird thing is it works for the save game name so its weird it doesn’t work for this.

The question is how did you reference the actor?

Because right now you only have a variable of the type but I couldn’t see anything which you reference the actor variable. You did set the name but it appears you did not set the actor in your widget.

The type is only the type. Like integer it float. It does not contain anything. There are potentially dozens of those actors in the level. Which one do you reference.

That is your issue.

Oh ok. So I have to tell the engine to use this specific actor… got it. I’ll see if I can figure that out. Thank you.

That’s why I said setting a variable in the level BP in an easy accessible place like gamestate would probably be easier :wink:

Because unless you reference this actor via a couple of bps the easiest way is “get all actors of class” and get the first index (0). That totally works but I personally prefer a direct reference.