How to reference a save game manager?

Hello! I have made a save game manager actor blueprint that basically contains all the functions I’ll need that are related to saving and loading the game. It contains the following functions:

Screenshot 2024-04-22 084824

What I’m struggling with is when I call my save game manager’s functions in another blueprint, I am not sure what to plug into the Target pin. I firstly tried this:

Screenshot 2024-04-22 084419

However, that returned this error:

So, I tried casting to the SaveGameManager but then I don’t know what to put in the object pin apart from the SaveGameManager variable itself (which of course doesn’t work). I am unsure of what object I would need to plug into this pin specifically.

I think I haven’t sufficiently set the SaveGameManager variable in the blueprint I am working in, but I’m not really sure how to do that either. Or, maybe I shouldn’t be using a save game manager at all and should be handling all of my save-related functions in another blueprint - I’m really not sure. If anyone knows how any of this works it would be great to know, thanks =)

1 Like

You could just put all of these functions into a function library, then you can just call them when you want.

But, if you want a specific manager, the why not use the game instance for that. It’s exactly what it’s for. You can also use an interface to make the calls, which means you won’t need to cast.

The trouble with your current setup, is you need to put a game manager actor in every level, and get a reference to it.

1 Like

If your manager is an Actor that is placed in the level, then use node “Get Actor of Class” to find it.

In general however, for such a thing, you might want to put it in a game instance subsystem or player subsystem. However afaik subsystems cannot be done in blueprints. Alternatively you could make it into a component added to your playercontroller or character class. That would make it more easily accessible and not dependent on placing the actor in every level.

That is, unless your actor is directly referencing other actors in the level - if you’re placing it in the level and using actor picker to specify which actors to save etc, then by all means stick to what you have and use GetActorOfClass.

1 Like

Thank you for both of your responses, they are extremely helpful! =)

However @ClockworkOcean - I tried putting all my functions into my game instance per your suggestion, and I was just wondering if you could elaborate on what you mean by using an interface to make the calls to the game instance? I think I understand what you mean but I’m not sure how exactly I’d carry that out.

1 Like

Blueprint interface, I mean

Without it, you have to do ‘get game instance’ → cast → ‘my game instance’ the whole time. With an interface, you can just ‘get game instance’ and make the call on it directly.

1 Like