Trying to apply Flipbook through C++

Hello!

So I’m having some trouble applying my flipbooks to my flipbook component. Here is my code:

CharacterAnimation = ConstructorHelpers::FObjectFinder<UPaperFlipbook> (TEXT("PaperFlipbook'/Game/Art/WalkBackward.WalkBackward'")).Object;

and then I set that with this code:

CharacterComponent->SetFlipbook(CharacterAnimation);

However, I keep getting this error:
C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/ConstructorHelpers.h(110) : error C2664: ‘void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)’: cannot convert argument 1 from ‘T *’ to ‘UObject *’
with
[
T=UPaperFlipbook
]

I would appreciate any help I could get on this. Thank you!

hi there!

  1. have you added the Paper2D module to your build.cs file?

like this:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" ,"Paper2D"});

My relationship with constructors is terrible! lol. I call my assets in the Beginplay function like this:

Suppose I have a flipbook variable in the header like this:

	UPROPERTY()
	UPaperFlipbook* myFlipbook;

then in the BeginPlay I do this:

void AMyActor::BeginPlay()
{
	Super::BeginPlay();

	myFlipbook = LoadObject<UPaperFlipbook>(nullptr,TEXT("PaperFlipbook'/Game/Textures/Flipbooks/MyEye.MyEye'"));
}

hope it helps!

4 Likes

That was it!! Thank you soo much

3 Likes