CSVとタイマー、タイムラインを使って時間ごとに球体を指定位置にテレポーテーションと消滅を繰り返し、出現位置でユーザーを軸にくねくね弧を描くように動くアクタを作っているのですが、
下図のようなコンパイルエラーが起きて躓いています
FloatCurveはこちらです
こちらのページを参考にタイムラインを使いました↓
どうかお力添えよろしくお願いいたします。
.h
#include "CoreMinimal.h"
#include "Components/SphereComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Components/TimelineComponent.h"
#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
#include "TimerManager.h"
#include "GameFramework/Actor.h"
#include "SoundLocation.generated.h"
UCLASS()
class VR1_API ASoundLocation : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASoundLocation(const FObjectInitializer& PCIP);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "SoundLocation")
USceneComponent* Scene;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "SoundLocation")
UStaticMeshComponent* SphereVisual;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "SoundLocation")
USphereComponent* SphereComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR")
FVector RelativeLocation = FVector(0.f, 0.f, 0.f);
UPROPERTY()
FTimeline MyTimeline;
UPROPERTY(EditAnywhere, Category = "Timeline")
UCurveFloat* FloatCurve;
public:
//CSVの行列データ
TArray<FString> RowData_m;
TArray<FString> row_m;
float Sound_m[256];
UFUNCTION(BlueprintCallable, Category = "CSVReader")
void LoadingTeiiData_m(FString FileName);
UFUNCTION()
void HandleProgress(float Value);
UPROPERTY(EditAnywhere, Category = "Timeline")
float MaxBounceHeight;
private:
FRotator ActorInitialRotation;
FRotator TargetRotation;
void waiting_m();
void moving();
void teii_m();
int32 i = 0;
FTimerHandle Timer;
float delayTime = 3.0f; // 待ち時間
FVector ResetPos = FVector(0.0f, 0.0f, 1000.0f);
FRotator ResetRot = FRotator(0.0f, 0.0f, 0.0f);
FVector SetPos = FVector(0.0f, 0.0f, 110.0f);
FString fname2 = (TEXT("teii2"));
};
.cpp
#include "SoundLocation.h"
#include "Engine/World.h"
#include "Engine/Engine.h"
// Sets default values
ASoundLocation::ASoundLocation(const class FObjectInitializer& PCIP) : Super(PCIP)
{
// 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;
AActor *actor = GetOwner();
// Add Scene component (for headset positioning), set to -110 to ensure headset starts at floor
Scene = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("SLBaseScene"));
Scene->SetRelativeLocation(RelativeLocation);
Scene->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
SphereComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("RootComponent"));
RootComponent = SphereComponent;
//SphereComponent->InitSphereRadius(40.0f);
SphereComponent->SetCollisionProfileName(TEXT("Pawn"));
// Add text
SphereVisual = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("VisualRepresentation"));
SphereVisual->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
if (SphereVisualAsset.Succeeded())
{
SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
SphereVisual->SetRelativeLocation(FVector(250.0f, 0.0f, 0.0f));
SphereVisual->SetWorldScale3D(FVector(0.8f));
}
void ASoundLocation::BeginPlay()
{
Super::BeginPlay();
APlayerController* PlayerController = Cast<APlayerController>(GetWorld()->GetFirstPlayerController()->GetPawn()->GetController());
//キーを押してテレポーテーション開始
if (PlayerController) {
EnableInput(PlayerController);
InputComponent->BindAction("Start_Teii_M", IE_Pressed, this, &ASoundLocation::teii_m);
}
//CSVデータを取得
LoadingTeiiData_m(fname2);
}
void ASoundLocation::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Timeline 再生中であれば DeltaTime 進めて実行
MyTimeline.TickTimeline(DeltaTime);
}
void ASoundLocation::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
FTimerManager& timerManager = GetWorldTimerManager();
// Handleに登録されたTimerの解放
timerManager.ClearTimer(Timer);
// このActorが所有するタイマーの解放
timerManager.ClearAllTimersForObject(this);
}
void ASoundLocation::LoadingTeiiData_m(FString FileName)
{
//CurrentDirectory取得
FString dir = FPaths::GameDir();
//ファイル名
FString filename = dir + FileName + ".csv";
//ファイル取得
FString csvFullData;
FFileHelper::LoadFileToString(csvFullData, *filename);
//列で分解
csvFullData.ParseIntoArray(row_m, TEXT("\n"), true);
//文字を登録
for (int j = 0; j != row_m.Num(); j++)
{
RowData_m.Add(row_m[j]);
GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, RowData_m[j]);
//float型に変換
Sound_m[j] = FCString::Atof(*RowData_m[j]);
}
}
//自分の周りに球体が消えている状態を表現
void ASoundLocation::waiting_m()
{
//アクタの位置と方向をリセット
SetActorLocation(ResetPos);
SetActorRotation(ResetRot);
GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, TEXT("Waiting..."));
//moving関数を再帰的に呼び出す
GetWorldTimerManager().SetTimer(Timer, this, &ASoundLocation::moving, delayTime, false);
//CSVから取得したデータの列の終わりが来たらタイマーをストップ
if (i == row.Num())
{
FTimerManager& timerManager = GetWorldTimerManager();
timerManager.PauseTimer(Timer);
i = 0;
}
}
//球体をテレポーテーションさせ、その場で自分を軸に
弧を描くようにくねくね動く
void ASoundLocation::moving()
{
if (FloatCurve)
{
FOnTimelineFloat ProgressFunction;
ProgressFunction.BindUFunction(this, FName("HandleProgress"));
MyTimeline.AddInterpFloat(FloatCurve, ProgressFunction);
MyTimeline.SetLooping(true);
ActorInitialRotation = TargetRotation = GetActorRotation();
TargetRotation.Yaw +=MaxBounceHeight + Sound_m[i] * 45;
MyTimeline.PlayFromStart();
}
FRotator NewRot = GetActorRotation();
SetActorLocation(SetPos);
NewRot = FMath::Lerp(ActorInitialRotation, TargetRotation, Alpha); //Scale our height by a factor of 20
SetActorRotation(NewRot, ETeleportType::TeleportPhysics);
GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, RowData_m[i]);
GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, TEXT("Waiting Compreted"));
i++;
//waiting関数を再帰的に呼び出す
GetWorldTimerManager().SetTimer(Timer, this, &ASoundLocation::waiting_m, delayTime, false);
}
//テレポーテーション開始用の関数
void ASoundLocation::teii_m()
{
GetWorldTimerManager().SetTimer(Timer, this, &ASoundLocation::waiting_m, delayTime, false);
}