I attached flipbook to USceneComponent and if I move flipbook inside the constructor flipbook would follow along as expected however when I try to move is outside the contractor the actual object moves but the flipbook would stay in its place for some reason…
// Fill out your copyright notice in the Description page of Project Settings.
#include "Meteor.h"
#include "PaperFlipbook.h"
#include "PaperFlipbookComponent.h"
#include "UObject/ConstructorHelpers.h"
#include "UnrealString.h"
// Sets default values
AMeteor::AMeteor():
speed(1.0f)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//Create RootComponent if it has not been already created
if(!RootComponent) {
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("MeteorBase"));
}
//Initialise the flipbook of the meteor
MeteorFlipBook = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("MeteorFlipBook"));
MeteorFlipBook->SetupAttachment(RootComponent);
MeteorFlipBook->SetRelativeRotation(FRotator(0,-90,90));
SetActorLocation(FVector(100,100,100));
}
// Called when the game starts or when spawned
void AMeteor::BeginPlay()
{
Super::BeginPlay();
SetActorLocation(FVector(0,0,0));
}
void AMeteor::SetFlipbook(FString Path) {
MeteorFlipBook->SetFlipbook(ConstructorHelpers::FObjectFinder<UPaperFlipbook>(*Path).Object);
}
// Called every frame
void AMeteor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}