Blueprint derived from UGameInstanceSubsystem

Hello, I have a problem with subsystems, I am trying to create Game Instance Sub System, and setup there few UPROPERTY and set them in blueprints
for that I have done abstract Subsystem

UCLASS(Abstract, Blueprintable)
class MYGAME_API USomeSubSystem : public UGameInstanceSubsystem

Then I can create Blueprint that derived from my C++ class
But there is a problem, thats works only when I have open this blueprint in editor ar least one time, what is the problem could be?

1 Like

You probably don’t have anything loading your blueprint at the right time so that subsystem initialization can see it. It only works in the editor because when it’s open it’s loaded before that process.

The real problem is that subsystems aren’t currently designed to be blueprintable. None of the important functions are implementable by blueprint so it’s not a recommended workflow.
You either have to fake it by spawning a singleton-y type actor or configure those things through ini settings instead of through blueprint.

@MagForceSeven
Hm, and thats quit problem, becouse I want to make some kind of manager that will live all game life even when we go to another level , so game instance is a good place for that and for making such objects subsystem is a good place, but I need to use some assets byt this manager and loading that like hardcode throught C++ not the best wey,
I also thaught to make UObject insode GameInstance, but there is another problem, when we make NewObject, thats require UWorld, that means that will be spawned in World and by gowing to another level it will be deleted,
So is there some ways to use UPROPERTY that will be always accessible?

Yeah, hardcoding them in C++ is bad but you can specify through config files with paths if your subsystem has TSoftObjectPtr’s.

Then you’re doing something wrong. UObjects don’t require a world to create them. They require a generic UObject “outer” but that could be anything, including the GameInstance itself.

@MagForceSeven
Ok then, when I am doing that in Game Instance

void UMyGameInstance::Init()
{
	Super::Init();
	MyController = NewObject<UMyController>(this, MyControllerBP, TEXT("MyController"));
}

New Object returns NULL, if it is not required UWorld that it should work, but it is not and I cant found the problem

There’s no way for me to tell based on what you’ve shared. You need to place a breakpoint and debug it. My guess would be that MyControllerBP isn’t loaded or assigned to properly.

Maybe start off by trying it without the MyControllerBP so that you’re doing it all in native.

What you have there should work just fine. If it’s returning a null pointer there it’s because of your inputs and not any sort of world ownership issues.

I have already tried to debug but shows nothing suspecious, MyControllerBP is not null and its ok,
Ok thank you very much for your help, I will continue looking this way then