Cannot compile class inherited from UGameInstanceSubsystem

Hi,

when I create a class

UCLASS()
class MY_API UMyGameInstanceSubsystem : public UGameInstanceSubsystem
{
	GENERATED_BODY()

public:
	//~ Begin USubsystem interface
	virtual bool ShouldCreateSubsystem(UObject* Outer) const override { return true; };
	virtual void Initialize(FSubsystemCollectionBase& Collection) override {};
	virtual void Deinitialize() override {};
	//~ End USubsystem interface
};

I receive a compilation error:

MyGameInstanceSubsystem.h(2): error : /Script/MY.MyGameInstanceSubsystem's superclass must be /Script/Engine.WorldSubsystem, not /Script/Engine.GameInstanceSubsystem

What do I do wrong? In Engine/Public/Subsystems/Subsystem.h it is written that supported subsystems are:

Currently supported Subsystem lifetimes are:

Engine → inherit UEngineSubsystem
Editor → inherit UEditorSubsystem
GameInstance → inherit UGameInstanceSubsystem
World → inherit UWorldSubsystem
LocalPlayer → inherit ULocalPlayerSubsystem

It seems like the Unreal Header Tool is not configured correctly to handle that. But I might be doing something wrong, that’s why I posted here.

(missing ‘U’ prefix from class name), otherwise, code looks fine. There is something on the 30th line but this is not provided in your pasted code.

Oh cr**. Sorry. I took the U by accident when I was covering project info. There is an extra U at the beginning and this error is still there. I will edit my original post to not confuse others. Thank you for your reply.

Right, also, I forgot that I cut out the class itself. The error is exactly about the class declaration, I will edit my original post about it too.

Does it work by using class wizard?

Well, it was naive by me. I started to change names and it compiled, so I started to investigate. I have used the UMyGameInstanceSubsystem in another file by accident and it was inheriting from a world subsystem. What a coincidence. I am happy I can continue now!

@knapeczadam Thank you for your help! I managed to figure it out somehow and I posted the answer. It was stupid by me, I should always keep the git commit workflow but I was lazy for a moment. Take care.

I cannot even run the editor because I cannot compile my code. It is interesting that you can create a blueprint version. I have to do something wrong.

Don’t blame yourself. Similar things happen with us on a daily basis. :slight_smile: