door sound triggers

This commit is contained in:
Johannes Theiner 2020-12-21 16:55:07 +01:00
parent 064087f161
commit a63a938a93
Signed by: joethei
GPG Key ID: 9D2B9A00FDA85BCD
9 changed files with 4 additions and 11 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.

View File

@ -9,11 +9,6 @@ URotatingActor::URotatingActor()
void URotatingActor::BeginPlay()
{
Super::BeginPlay();
AudioComponent = GetOwner()->FindComponentByClass<UAudioComponent>();
if (!AudioComponent)
{
UE_LOG(LogTemp, Error, TEXT("No audio component found on: %s !"), *GetOwner()->GetName());
}
}
void URotatingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
@ -42,10 +37,11 @@ void URotatingActor::Rotate(const FRotator TargetRotation)
{
tempRotation = (TargetRotation.Yaw < 0) ? 1.f : -1.f;
}
if(AudioComponent != nullptr && !soundHasBeenPlayed)
UAudioComponent * Audio = GetOwner()->FindComponentByClass<UAudioComponent>();
if(Audio != nullptr && !soundHasBeenPlayed)
{
AudioComponent->Play();
Audio->Play();
soundHasBeenPlayed = true;
}
}

View File

@ -31,9 +31,6 @@ public:
UPROPERTY(EditAnywhere)
float TargetAngle = 90.0f;
UPROPERTY(EditAnywhere)
UAudioComponent * AudioComponent;
UPROPERTY(EditAnywhere)
float RotationSpeed = 15.f;