This commit is contained in:
Finn Wundram 2021-03-10 22:59:14 +01:00
commit 1a0af4e131
49 changed files with 47 additions and 30 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,8 @@
#include "Components/AudioComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/World.h"
#include "Engine/Public/TimerManager.h"
URotatingActor::URotatingActor()
{
@ -33,6 +34,28 @@ void URotatingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorC
}
void URotatingActor::Rotate(const FRotator TargetRotation)
{
FTimerHandle handle;
if(RotationDelay == 0)
{
Move(targetRotation);
}else
{
GetWorld()->GetTimerManager().SetTimer(handle, [this, TargetRotation]() {
Move(TargetRotation);
}, RotationDelay, 1);
}
}
void URotatingActor::Rotate()
{
FRotator rotation = GetOwner()->GetActorRotation();
rotation.Yaw = TargetAngle;
Rotate(rotation);
}
void URotatingActor::Move(const FRotator TargetRotation)
{
this->targetRotation = TargetRotation;
rotating = true;
@ -53,8 +76,8 @@ void URotatingActor::Rotate(const FRotator TargetRotation)
if (Audio->ComponentHasTag("location"))
{
UGameplayStatics::PlaySoundAtLocation(GetOwner(), Audio->Sound, GetOwner()->GetActorLocation(),
GetOwner()->GetActorRotation(), 1, 1, 0,
Audio->AttenuationSettings, nullptr, GetOwner());
GetOwner()->GetActorRotation(), 1, 1, 0,
Audio->AttenuationSettings, nullptr, GetOwner());
}
else
{
@ -64,10 +87,3 @@ void URotatingActor::Rotate(const FRotator TargetRotation)
soundHasBeenPlayed = true;
}
void URotatingActor::Rotate()
{
FRotator rotation = GetOwner()->GetActorRotation();
rotation.Yaw = TargetAngle;
Rotate(rotation);
}

View File

@ -34,7 +34,7 @@ public:
float RotationSpeed = 15.f;
UPROPERTY(EditAnywhere)
float RotationDelay = 2.f;
float RotationDelay = 0.f;
UPROPERTY(EditAnywhere)
bool Negative = false;
@ -44,4 +44,5 @@ private:
bool rotating;
bool soundHasBeenPlayed;
float tempRotation;
void Move(FRotator TargetRotation);
};