x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

タイムラインを使ったアクタがうまくコンパイルできない

CSVとタイマー、タイムラインを使って時間ごとに球体を指定位置にテレポーテーションと消滅を繰り返し、出現位置でユーザーを軸にくねくね弧を描くように動くアクタを作っているのですが、

下図のようなコンパイルエラーが起きて躓いています alt text

FloatCurveはこちらです alt text alt text

こちらのページを参考にタイムラインを使いました↓ http://orfeasel.com/consuming-timelines-using-c/

どうかお力添えよろしくお願いいたします。

.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);
 
 
 }
 


Product Version: UE 4.19
Tags:
error1.jpg (36.8 kB)
curve.jpg (72.5 kB)
curve2.jpg (3.5 kB)
more ▼

asked Feb 05 '19 at 03:42 AM in Japanese

avatar image

masabo07
14 1 1 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

void HandleProgress(float) がcpp側で実装されていないようですが、実体はどこにあるのでしょうか?
header側にのみ定義してcpp側で実装されていないのであれば、おそらくそれが原因と思われます

more ▼

answered Feb 05 '19 at 04:30 AM

avatar image

T_Sumisaki
3.9k 28 4 8

avatar image masabo07 Feb 05 '19 at 06:10 AM

あちらのHandleProgressの部分を少し改変して組み込んだらうまくコンパイルできました

しかし肝心の球体が動いていない状態でテレポーテーションもその場で消えたりついたりを繰り返しています

コンストラクタに以下の文を追加してもくねくね動きません

 MyTimeline.SetTimelineLength(1.0f);

 static ConstructorHelpers::FObjectFinder<UCurveFloat> Curve(TEXT("CurveFloat'/Game/StarterContent/MovingCurve.MovingCurve'"));
 check(Curve.Succeeded());

 FloatCurve = Curve.Object;

質問の内容が変わって申し訳ないですがお力添えよろしくお願いいたします

.cpp

void ASoundLocation::moving() { if (FloatCurve) { FOnTimelineFloat ProgressFunction; ProgressFunction.BindUFunction(this, FName("HandleProgress")); MyTimeline.AddInterpFloat(FloatCurve, ProgressFunction); ActorInitialRotation.Yaw = Sound_m[i] * 45; TargetRotation = ActorInitialRotation = GetActorRotation(); TargetRotation.Yaw += MaxBounceHeight;

     MyTimeline.SetLooping(true);

     MyTimeline.PlayFromStart();         
 }

 SetActorLocation(SetPos);
     GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, RowData_m[i]);

 GEngine->AddOnScreenDebugMessage(-1, 8.10f, FColor::Yellow, TEXT("Waiting Compreted"));
 i++;

 GetWorldTimerManager().SetTimer(Timer, this, &ASoundLocation::waiting_m, delayTime, false);

}

 void ASoundLocation::HandleProgress(float Value )
 {
     //アクターの新しい場所を設定する
     FRotator NewRotation = FMath::Lerp(ActorInitialRotation,TargetRotation,Value);
     SetActorRotation(NewRotation);
 }
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question