Loading Screen gameinstance question

First off I’m very new to c++ so I don’t have much of an idea. So any help would be greatly appreciated.

I was trying to follow this tutorial because from what I can gather it is the best and only way to get a loading screen, but when I build after ‘the code’ section I get errors such as ‘FLoadingScreenAttributes is undefined’.
I’m sure I have done something stupid and put something in the wrong area.

I created a new 4.10 code project called ‘PuzzleGameCode’ and created a c++ class of gameinstance and saved it in the default directory.
I added the line ‘GameInstanceClass=/Script/MyGame.MyGameInstance’ to the DefaultEngine.ini file. Do I need to change the ‘MyGame’ to ‘PuzzleGameCode’?

I then opened ‘PuzzleGameCode.Build.cs’ and added “MoviePlayer” after “InputCore”.

Now this is the bit I probably screwed up.
I opened both the MyGameInstance.H and the MyGameInstance.cpp files and added the relative bits from the tutorial. After saving I try to build it and that is when the errors show.
Was I meant to add it to other header and cpp code?

Sorry if this is a really stupid question but any help will be very appreciated.

Hi Tocs-

Yes, you need to change the ‘MyGame’ to ‘PuzzleGameCode’, so it would be ‘GameInstanceClass=/Script/PuzzleGameCode.MyGameInstance’ in ini-file.
Or better you can do it in editor Edit->Project Settings->Maps&Modes

About code - you were right. You should add code to the MyGameInstance.H (here goes code from Header section from tutorial) and the MyGameInstance.cpp (and here goes section CPP). Just don’t forget compare naming of your GameInstance class and class from tutorial, but as I can see they match each other.

If changing of .DefaultEngine.ini file doesn’t help, give please error’s text from output.

EDIT: It seems you need include definition file for moview player. Add this line in MyGameInstance.cpp file:
#include “Runtime/MoviePlayer/Public/MoviePlayer.h”

Thank you so much. I had the ini file correct already (I was trying a heap of things) but adding the definition file at the start made it work, which is odd seeing as there is no mention of it in the tutorial.


It now builds but it doesn’t seem to have a loading screen. All it does is freeze the current view until the next map is loaded.
Do you know what would be wrong? Or do I need to do more to get it working?

Where did you create your GameInstance class? If you created it through Unreal Editor interface, then editor had to add all macroses like UCLASS for you. If you created class yourself then decorate your class(in *.h) like follow:

class PUZZLEGAMECODE_API UMyGameInstance : public UGameInstance
	virtual void Init() override;
	virtual void BeginLoadingScreen();
	virtual void EndLoadingScreen();

See this link for exploration. Just such thing like macroses usually is considered pretty obvious, so people could omit it

make sure you are testing in standalone mode, since the MoviePlayer component is disabled in PIE.

Thanks V0j4 thats what was wrong.
Also thank you Alkohol for your help earlier. It looks like I’m going to learn some c++.