türen mit sound
This commit is contained in:
parent
c7d609de35
commit
084c927cd5
|
@ -61,3 +61,6 @@ PhysXTreeRebuildRate=10
|
|||
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
|
||||
|
||||
|
||||
|
||||
[CoreRedirects]
|
||||
+PropertyRedirects=(OldName="/Script/BuildingEscape.RotatingActor.udioComponents",NewName="/Script/BuildingEscape.RotatingActor.Sounds")
|
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.
|
@ -1,5 +1,7 @@
|
|||
#include "RotatingActor.h"
|
||||
|
||||
#include "Components/AudioComponent.h"
|
||||
|
||||
|
||||
URotatingActor::URotatingActor()
|
||||
{
|
||||
|
@ -20,7 +22,8 @@ void URotatingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorC
|
|||
if (Rotation.Equals(targetRotation, 1.0f))
|
||||
{
|
||||
rotating = false;
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
Rotation.Add(0.0f, DeltaTime * RotationSpeed * tempRotation, 0.0f);
|
||||
GetOwner()->SetActorRotation(Rotation);
|
||||
|
@ -33,17 +36,32 @@ void URotatingActor::Rotate(const FRotator TargetRotation)
|
|||
this->targetRotation = TargetRotation;
|
||||
rotating = true;
|
||||
tempRotation = (TargetRotation.Yaw < 0) ? -1.f : 1.f;
|
||||
if(Negative)
|
||||
if (Negative)
|
||||
{
|
||||
tempRotation = (TargetRotation.Yaw < 0) ? 1.f : -1.f;
|
||||
}
|
||||
|
||||
UAudioComponent * Audio = GetOwner()->FindComponentByClass<UAudioComponent>();
|
||||
if(Audio != nullptr && !soundHasBeenPlayed)
|
||||
TArray<UAudioComponent*> Audios;
|
||||
GetOwner()->GetComponents<UAudioComponent>(Audios);
|
||||
|
||||
if (Audios.Num() == 0) return;
|
||||
if (soundHasBeenPlayed) return;
|
||||
|
||||
for (auto Audio : Audios)
|
||||
{
|
||||
Audio->Play();
|
||||
soundHasBeenPlayed = true;
|
||||
if (Audio->ComponentHasTag("location"))
|
||||
{
|
||||
UGameplayStatics::PlaySoundAtLocation(GetOwner(), Audio->Sound, GetOwner()->GetActorLocation(),
|
||||
GetOwner()->GetActorRotation(), 1, 1, 0,
|
||||
Audio->AttenuationSettings, nullptr, GetOwner());
|
||||
}
|
||||
else
|
||||
{
|
||||
Audio->Play();
|
||||
}
|
||||
}
|
||||
|
||||
soundHasBeenPlayed = true;
|
||||
}
|
||||
|
||||
void URotatingActor::Rotate()
|
||||
|
@ -51,5 +69,4 @@ void URotatingActor::Rotate()
|
|||
FRotator rotation = GetOwner()->GetActorRotation();
|
||||
rotation.Yaw = TargetAngle;
|
||||
Rotate(rotation);
|
||||
|
||||
}
|
||||
}
|
|
@ -3,7 +3,8 @@
|
|||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "Components/AudioComponent.h"
|
||||
#include "Kismet//GameplayStatics.h"
|
||||
|
||||
|
||||
#include "RotatingActor.generated.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue