How to connect Game Instance data to Save game

I know how bought of these work. What I don’t know how do they communicate to each other. How do you pull Game Instance data and feed it in to Game Save. Would it do with Cast to Game Instance and connected to Cast to Game Save in that kinda order?? Thank you.

Would it do with Cast to Game Instance
and connected to Cast to Game Save in
that kinda order?

Yes.

But wouldn’t it be easier to have the SaveGame object IN the GameInstance. Would save you a lot of running forth and back… Besides, GameInstance is globally available, easy to access and, most importantly, persistent.

Thank you for reply!!! You been a life saver!!

So How would I put Save Game object in the Game Instance?? Could you please Guide me trough the sleepless nights. So I can return to normal life. Thank you!!!

Jesus I didn’t even see the reply and been looking for answer on the net all day. THANK YOU, THANK YOU. Thank you for VISUAL and you time!!! Let me please dig in to these and please stay with me cause I’m about to throw my PC out the window. lol. I’ll let you know if I managed to hook it up correctly!! Thank you again!!!

There’s more than 1 way of doing this. See if this method suits you:

SaveGameObject has a custom event that takes data you want to save:

250901-savegameobject.png

GameInstance has 2 functions - Save & Load


So you can do this anywhere in the game:

Do use the same slot name, otherwise it’s not going to work well, obviously.

Sure thing. Just hammer at it until it works :slight_smile:

I tested this very briefly, seems to save stuff.

I tested the script I posted briefly but after running the Save function once, next time you launch and run just Load, it read the data correctly.

In pic 1 then:

  • create a text variable in the game object
  • add text variable input to the custom event in the save game input
  • add text variable to the save game function

In your widget:

  • get text block > get text
  • run Save from the 2nd pic

edit: I mean, my example actually saves text. So you can use it as is with the widget. No need to change anything, actually.

Ok these brings me to another question. Since I have Game instance all working and is showing me proper score and all. I would like to then take that Text Block (0) or what ever the score it is and save it to my game save. I just don’t know how to cast to text block and all the nodes that come off it. I can make Text variable inside the Text graph but I don’t know how to use them together with Game Save. In short wouldn’t be Ok if I save the text information and then load back from Game save and display it with High Score text? I’m not supper advance with all these so I really need simple explanation. Sorry and Thank you again!!!

Also let me explain my project. It has only one level an main menu level. The points collector is trigger box that’s been cast to game instance with integer + integer. The in game score text and the main menu high score text all get information from Game Instance which all works grate until I close the game in editor. Than all is back to 0.

Thank you for reply. I’m just not sure I understand the get text variable because the text I’m referring to is Text Block (Score) I need to hand over these Score text information to Game Save some how. For give me if I’m not connecting to what your already explain to me. I’m slow that way. Thank you!!!

Sorry these is to complicated for me. I’m already lost at the second point. Do I need to connect second point you mention to my trigger box? Where exactly does text variable input and custom event and save game input all all connect? Would they go in to the BP or my Trigger box overlap?? Sorry I’m really that basic. Thank you.!!!

Do I need to connect second point you
mention to my trigger box?

When you are ready to save data you just run this:

250908-capture.png

Connect it to a trigger box. The trigger box should now get access to the widget > get text block > get text and you plug that that text into the Text to Save pin above.

Sorry just got back. Thank you a million for the reply!!! For some reason I’m starting to see a light at the end of the tunnel. I manage to get some stuff going but I don’t know how did you get Text to Save pin. I just got Save Data so far no Text to Save. Here are the pic. Sorry I know your about to kill me any minute now. Just please work with me on these one I know I can get it to work with your help!
For some reason text block 334 dosen’t wana connect to my Save Data. What am I missing?? Thank you!!

alt text

How do I get widget reference. That’s sort of what I been looking for I think. Thank you guys. !!

Yes exactly! What I need is a text block reference to then save it with Game Save. How would I get that text block 334 reference. So what ever the current score is inside that text that would be the score I would like to save let’s say when I exit the game and go to main menu. Could you please show me in a visual way. Just the text reference. Thank you a 3 million.

When you create a custom event “Save This”, you can click on the red event node and add an “input” on the right hand details panel. He called this input “Text To Save” and made the type a String variable. “Text Block 334” is a widget text block variable, that would not be a variable from a Save Game Object. You need a widget reference for that variable to make any sense.

Could these tut be correct. Can these actually work??

Depends where you create the widget. Is it a viewport widget? A widget component on an actor etc This will determine how you go about getting a reference to the widget variables.

Did you just make a YT tutorial about this?! o_O