Download

How to load variables from a Blueprint?

I have a simple setup; a scene with the ThirdPersonCharacter, a Widget with a Speed slider, and a Save Game BP. “CC” means Character Customization, “SG” means Save Game in case you were wondering about my variable naming conventions.

In screenshot 1 is the Save Game BP. It has one float variable.

In screenshot 2 is the Widget. I have a slider that outputs to a variable, that variable gets multiplied by 600 for the speed, then creates and Saves Game to Slot. This is all under Event Tick since I would like the player to be able to change the speed with the slider and have the Save Game BP updated automatically.

In screenshot 3 is my ThirdPersonCharacter BP. I have a cast to SaveGame to pull that variable, and then output that to Max Walk Speed.

For some reason the casting in my ThirdPersonCharacter BP isn’t being executed since I have a Print String at the end, and my character’s speed isn’t adjusting.

Anyone have any thoughts? Thanks!

You’re not loading the save game. Look at this screen from the documentation:

https://docs.unrealengine.com/latest/images/Gameplay/SaveGame/Blueprints/LoadGameBP_2.jpg

https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html

That loading did the trick, but I still cant get the slider to change the speed. The Event Tick in my Widget updates the variable, and when clicking the button it should save that data to the PlayerSG blueprint.

I also dont understand the SaveGameIstance is the documentation. Is that needed to pull the variable?

Well my loading is working since if I change my variable inside the PlaySG blueprint, it changes the players speed. For some reason my saving isn’t working. Any thoughts?

Yeah you’re missing the save game function. From your cast to PlayerSG type ‘save’ and use the save to game slot function. You should be good to go after that

> Well my loading is working since if I change my variable inside the PlaySG blueprint

I don’t think so. Unless it’s not in the screenshots you aren’t running the ‘Load game from slot’ function. You’re casting to your save game from nothing. That’s not how casting works exactly. A cast is when you are trying to change an object from one type to another, aka type conversion. In this case you want to take your object from the load game function and cast it to your custom type. Hope that helps.

But you should also check to make sure the save game exists before trying to load it

I got it working now. Thanks for your help!