2D animation ConstructorStatics error

Hello everyone

I’m having a trouble setting 2D flipbook animation into C++, this problem wasn’t there in the past.
I used to do this method without any problems but now when I do
header:

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FlipbookComponent", meta = (AllowPrivateAccess = "true"))
		class UPaperFlipbookComponent * paperComponent;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FlipbookComponent", meta = (AllowPrivateAccess = "true"))
		class UPaperFlipbook* paperSoPWalk;

Cpp:
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional paperSoPWalkAsset;

	FConstructorStatics()
		: paperSoPWalkAsset(TEXT("PaperFlipbook'/Game/2DSideScroller/Sprites/RunningAnimation.RunningAnimation'"))
	{
	}
};
static FConstructorStatics ConstructorStatics;
paperSoPWalk = ConstructorStatics.paperSoPWalkAsset.Get();

gives me bugs
apparely the problem coming from this line
paperSoPWalk = ConstructorStatics.paperSoPWalkAsset.Get();

It’s a compiler error so you need to check the syntax, usually what i do is:

static ConstructorHelpers::FObjectFinder<UClass> PlayerPawnObject(TEXT("/Game/Characters/Scavenger/Player_BP.Player_BP_C"));

	if (PlayerPawnObject.Object)
		DefaultPawnClass = PlayerPawnObject.Object;

So in your case you can try:

    static ConstructorHelpers::FObjectFinder<UPaperFlipbook> PaperFlipbookObject(TEXT("/Game/2DSideScroller/Sprites/RunningAnimation.RunningAnimation")); // If this doesnt work try with "/Game/2DSideScroller/Sprites/RunningAnimation"
    
    	if (PaperFlipbookObject.Object)
    		Class = PaperFlipbookObject.Object;

Hi, thank you for your response

It didn’t work

The screenshot doesn’t help, disable the warnings and show only the errors.

these are the errors
three of them

***Severity Code Description Project File Line Suppression State
Error C2664 ‘void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)’: cannot convert argument 1 from ‘UPaperFlipbook *’ to ‘UObject *’ ManSide3 E:\Program Files\Epic Games\UE_4.18\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h 109
Severity Code Description Project File Line Suppression State
Error Failed to produce item: ManSide3 1

Severity Code Description Project File Line Suppression State
Error MSB3075 The command ““E:\Program Files\Epic Games\UE_4.18\Engine\Build\BatchFiles\Build.bat” ManSide3Editor Win64 Development " -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command. ManSide3 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 41***

And the previous code that I used and the one that you suggested me to try:

Cpp:
	struct FConstructorStatics
	{
		  ConstructorHelpers::FObjectFinderOptional<UPaperFlipbook> RunningAnimAsset;
	FConstructorStatics()
		: RunningAnimAsset(TEXT("PaperFlipbook'/Game/2DSideScroller/Sprites/RunningAnimation.RunningAnimation'"))
		{
		}
	};
	static FConstructorStatics ConstructorStatics; 
	RunningAnim = ConstructorStatics.RunningAnimAsset.Get();


Cpp:
		static ConstructorHelpers::FObjectFinder<UPaperFlipbook> PaperFlipbookObject
		(TEXT("PaperFlipbook'/Game/2DSideScroller/Sprites/RunningAnimation.RunningAnimation'"));

	if (PaperFlipbookObject.Object)
		Class = PaperFlipbookObject.Object;

Have you included the PaperFlipbook header and added the Paper2D Module?

I thought “PaperFlipbookComponent.h” was enough, like the previous versions of UE4.
I never thought the missing “PaperFlipbook.h” could be the problem.
Thank you so much man, I have been trying to solve this problem for days :).

Good to know, if it worked and you liked my help please upvote and mark my answer as correct :slight_smile:

I meant my answer :smiley: I’ll create one so you can mark it as correct.

Make sure you include “Paper2D” module and include “PaperFlipbook.h”.

Sorry, I’m new to this site :). still learning

No problem :slight_smile: