Hey guys, I have a volume slider set up that adjusts the master volume through all of my levels, and it has a binding being controlled by a volume float variable so that it saves in whatever position it was last left at. But, despite the slider saving based on the value of that float variable, and successfully adjusting the volume, the variable is acting like it’s not saving, so every time I exit out of the game and start it again, the volume is back up to 1.0, which is the default value of the float. Moving the slider gets the volume adjusting again, but it always resets after exiting the game. Is there a way to get the slider value to save? I thought Save Game to Slot would work, but it doesn’t seem to be wanting to. Thanks in advance!
Ok I tested this and was able to achieve what you are looking for
Please note that the setup I show here does not use or a require any bindings. Bindings in widgets “Tick” every frame and should be avoided when possible.
I create the gamesave inside the character BP - so that it is easily accessible in the widget
Let me know if run into any problems during this setup
Hey, thanks for the setup! I just gave this a quick try after removing the binding. The slider works and saves in place, but when trying to use it to control the volume on the Set Sound Mix Class Override node, the volume still resets every time I exit and start the game. Could this be a problem caused by the Override node itself?
You would have to set up the “volume” variable in the same way as the “slider” value, which you see works.
Sorry for the late response, it’s been a busy weekend. Unfortunately, I still can’t get the volume variable to save properly. The slider position saves and adjusts the volume, but the volume always resets back to the default value until I use the slider again
Np pal - let me see the logic. Show me where you call the audio, what you’re using, etc Also show me what’s going on inside the gamesave and logic responsible for saving this variables info
Okay, bear with me here, as this is my first project I’ve ever attempted blueprint scripting in, so the set up may not be as clean as it should be. Here’s the screenshots of my Sound Class and Mix (admittedly, I’m not 100% sure I have this part set up correctly, though it seems to work), my volume slider nodes in the settings widget you showed me how to set up, and one of the game modes that pushes the sound mix. I have a different game mode for each difficulty of the game, so on BeginPlay I have to push the sound mix in every game mode in order for the volume changes to work across the whole game, since pushing it in a Game Instance didn’t seem to do anything. As for the save game, I’ve been using it to store the variables I need saved, and I’ve just been casting to the save game and saving the set variables whenever I need them saved (up until you posted your screenshot earlier, I was unaware you could just set it up in any easy-to-access blueprint and get it’s variable, but it hasn’t really caused a hassle this way either. It’s just a little bit more cluttered).
I tried this solution but I get "Error accessed None. What am I missing? Thanks
Accessed None means that the value that is trying to be set is not yet (or just isn’t) initialized/known by the node trying to use it. The error message should say which variable is not being set. It can also be that you are using a value that you have no initialization for.
If this happens at the very start of gameplay, it may indicate that it is too soon to attempt to use the variable involved.
By checking IsValid on the variable before attempting to use it, you can do something like a delay before proceeding so the value isn’t attempted until ready. If it is an initialization you haven’t allowed for, it will never be set and will need to be addressed.
Kind of a generic answer but, I can’t say anything specific without the complete error message, but you should be able to figure out which is failing to be set by the rest of the content of the message. Here is an example of one such message from my log:
Blueprint Runtime Error: “Accessed None trying to read property CharacterReference”. Node: Set Direction Graph: EventGraph Function: Execute Ubergraph My Anim Blueprint Blueprint: MyAnimBlueprint
This means that my variable Direction in MyAnimBlueprint is trying to be set with a invalid value due to CharacterReference not being set (e.g., null). In this particular case, it’s happening at startup because the value being used to set CharacterReference hasn’t been provided to the blueprint yet so it’s property called Direction can’t be used in the Set node. Each case will be different as to the solution, but you know where to look from the error message.