Save Slider Values

So I recently made a master volume slider, and it’s working all nice and dandy. The only problem is when I exit the settings screen and go back to it, the slider is back at 100%. Now the music stays at the volume which I set it to, which is good. I just want to know how to keep the slider position to stay where I left it.

Here’s what I have

293968-lbp.png

Hi,
You can store the value somewhere.
Then when you are showing the widget containing the slider, you can use the Set Value from Event Contstruct.
Getting the value from where you stored it.

I’m pretty new to all this, how do I call the slider value?

And how would I set the value?

Do you want to save it so that it persists even after you reopen your game or in the current session only?. Also to get the slider value, go to your widget bp designer and select the slider you want to get the value of, in the details section on the top you will see a checkbox for Is variable or something similar. click on that. now in the widget bp area. in the variables section you will see that the a variable with the slider’s name will appear. you can use that variable to get the value of the slider.

When you have set the value to another variable which lies in something like the player character you can use the set value node and use the slider variable as target. Basically what METAL GEAR GAMES has shown. this needs to be done in the widget bp which has the slider.

One that saves when you reopen the game. Also, could you show screenshots of what you’re talking about. I’m all a little confused here sorry lol

If you want to save slider so that it holds its value when you reopen your game, you should use a SaveGame Object. For more info on this topic: Saving and Loading Your Game in Unreal Engine | Unreal Engine 5.1 Documentation, or you could search for it on YT.

In this SaveGame Object you can add a variable (float) where you can store the slider value.

294021-savegameexample.png

When you open the widget containing the slider, you want to load this variable and set the slider’s current value to it using the “Set Value” node. You must make sure that the slider has “Is Variable” checked, as SupDeity pointed out.

294023-sliderdetails.png

When you change the slider’s value, save the new value to the SaveGame Object.

2 Likes

It’s a variable you create yourself, you can see it on the left hand side in the variable list. Create a new variable, select it and set its type to Your_Save Game - Object Reference in the Details panel.

edit: I’ll just add that you need to create a save game object first.

Where do you get the “Save Game Object” from? sorry I’m a little slow to this stuff

How do you get the “Target” to appear underneath The Set Slider Variable node

You can’t make it appear. It simply means the variable is a part of another actor and the node needs a target to, well, target a specific actor.

I may want to read up on Variables and Save Games.

The cast fails for me at event construct, how do I fix this?