Download

Create character customization variables for Game Save.

I’m new to UE4 and trying to make a “Game Save” for character customization. At runtime, the player chooses 1 of 5 torsos to display on an avatar. Player then presses a game save button to save the avatar configuration. Then, the next time the game starts up, the previous torso mesh is still on the avatar.
I already have UMG buttons swapping out the torso meshes at runtime.

Question 1: If torso B is visible, how do I tell the “Game Save” that torso A, C, D, and E are invisible?

Question 2: How do I load the “Game Save” blueprint at runtime to load the saved out character customization?

Below is a screen grab of the blueprint.

Check out video #21 on how to perform a save/load cycle. You need to save the data to a save game object and load it from the save game object for the effect to persist when the game starts up after a full shut down.

As for your first question, you could save an “enum” value of which torso is visible and use “switch” on enum to determine which one to display. The enum would set the “torso” variable and you would then use a node to “set” the visibility of that particular torso to “visible” have all others default to hidden.

Hey, Nebula Games Inc, interesting idea. How would you blueprint this out? I’m new to blue prints.
Thanks for making the Game Save video. :slight_smile:

Create an Enum variable, inside the Enum have the possible options for your torsos. I wouldn’t have them all there honestly and then “hide” 4/5, that’s not a great way to do it. Just use a node like “Set Static Mesh” and make the input “mesh” a variable. Using the enum, you will “Set” this variable to 1 of 5 options. When the player selects a particular torso using the UMG buttons, the buttons should “Set” the enum value to their particular torso and then call a function that uses a “Switch on Enum” (the enum being your custom torso enum name) to display the appropriate torso. When you want to save, you save this enum value to a save game object. When you load the game back up, pull from the save game object and set the Enum variable and then call the function to place the appropriate torso on the avatar. By using an enum you save yourself the headache of setting visibility on 5 torsos each time the player selects a new one. Here we are just swapping out one mesh for another.

Created an Enum with the visibility options I want and then save it to a variable.
I tested the UMG buttons and they still swap out the clothing correctly. I even get the correct print string when the clothing swaps out at runtime.
How would I get the variable into Game Save?

I posted a link above that goes over how to create a save/load cycle. You just need to add those variables to the list of data you save out to slot. Then when you load it back up pass that data back to the game instance or character BP or wherever you are setting all this stuff.

Also, I hope you know that you have saved this data to 3 separate slots. So when you try and load it in, you would need to pull the data out of all 3 slots if you need t-shirt, torso and long sleeve shirt data.

O, I thought the saved out index needed to be the same as the index in the Enum?

Question, when you created your “Save Game” function variables, you used a Bool and an Integer. Since I am using an ENUM, do I need 3 variables? Do I use a string to store the display name, an integer to store the index, and a text to store the description? Or, can I use one variable type?

Store the variables you want to save. Don’t over complicate this. You save an enum just the same as any other variable.

As for you above screen shot with the saved boolean, yes, just add the enum you want to save to the list exactly how you saved the boolean.

Hello Nebula Games Inc, I’m going through your excellent video and I found something I did wrong :frowning: . Can I ask about time index 6:05? You call the function “Same Game” from a “Game Instance Ref.” Your “Game Instance Ref” seems to be a save game variable type. However, I cannot plug in my “Save Game Ref” into the Save Game target.
Even if I create a new unique Save Game variable, it will not plug into the target of the Save Game object.

How can I fix my Save Game Ref variable? Or, should I ask, how did you create your “Game Instance Ref” variable?

I can drag out a connection and “Promote to Variable” but, I can not change that promoted variable to a save game variable.

If you watch this video you will see at 2:25 I begin creating a “FUNCTION” called “Save Game” from my game instance. The “Save Game Ref” does nothing but “get” or “set” variables as part of either a load or save function within my game instance. What you seem to have done is not what I did in my tutorial. You are creating a save game object, saving it as a reference and immediately saving the game to a slot. Then you are trying to do things with the save game reference. This is not what I was doing. I created a function in my game instance that I can call when I want to save the game and it handles all the heavy lifting of actually saving variables. If you look at how that function is set up, I create a save game object first, pull out “setters” for all the variables stored in the save game object, and then set them to the game instance values of those variables. Finally, I “Save Game To Slot”. All within the game instance. The reference to the save game object doesn’t call any functions because there is nothing in the save game object besides the empty variable containers that I fill with data from the game instance when the function to save is called.

https://www.youtube.com/watch?v=sYR99u174Aw

Nebula Games Inc, you’re the best! Thank you. :slight_smile: I’m new to blue prints and thank you for helping me. I’m gunna re-work the blueprints like you suggested. :slight_smile:
I have the Save game function and Load game function set up like your video. But I still need help understanding how to hook up the displayed clothes into game save.

I’m still having trouble figuring out how to hook up the displayed clothing with the ENUM to the Game Save.

I think, after I have Save Game at runtime figured out, I need to figure out what to do “On Begin Play.” I think I need a system to “check what clothes in Game Save are displayed on the player.” Then, turn on visibility of the clothes from that file.

Does that sound correct?

Game Instance Ref wire can not call the Save Game Function.

How do I get the selected clothing to go invisible if the player clicks on a different button to display a different Torso Clothing? Below, is the awesome suggestion, from Nebula Games Inc.

  1. Create an Enum from the content browser, create an entry for each torso you have.
  2. Start all torsos default hidden.
  3. When the player selects one, have that button set the Enum to the torso type they selected.
  4. Then, call a function that sets the visibility of each torso based off the enum.

Currently, when I press the button, the previous selection stays visible.

Is there a better way to make the other components invisible(hidden) when a particular component is visible?
This is a what I have working, currently.

Looks fine to me. But why isn’t the “Save Game To Slot” node connected in the first image??