void AFloater::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (bShouldFloat)
{
FVector NewLocation = GetActorLocation();
NewLocation.Z = NewLocation.Z + FMath::Sin(RunningTime);
SetActorLocation(NewLocation);
RunningTime += DeltaTime;
}
}
Floater가 위/아래로 움직인다.
좀 더 테스트하기 쉽게만들기
void AFloater::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (bShouldFloat)
{
FVector NewLocation = GetActorLocation();
NewLocation.Z = BaseZLocation + Amplitude * FMath::Sin(RunningTime);
SetActorLocation(NewLocation);
RunningTime += DeltaTime;
}
}
// Amplitude
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Floater Variables")
float A{};
// Period
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Floater Variables")
float B{};
// Phase Shift
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Floater Variables")
float C{};
// Vertical Shift
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Floater Variables")
float D{};
void AFloater::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (bShouldFloat)
{
FVector NewLocation = GetActorLocation();
NewLocation.Z = BaseZLocation + A * Amplitude * FMath::Sin(B * RunningTime - C) + D;
SetActorLocation(NewLocation);
RunningTime += DeltaTime;
}
}