#include "TriggerOpenDoor.h" UTriggerOpenDoor::UTriggerOpenDoor() { PrimaryComponentTick.bCanEverTick = true; } void UTriggerOpenDoor::BeginPlay() { Super::BeginPlay(); AudioComponent = GetOwner()->FindComponentByClass(); if (!AudioComponent) { UE_LOG(LogTemp, Error, TEXT("No audio component found on: %s !"), *GetOwner()->GetName()); } } void UTriggerOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); if (!doorOpen) { TArray overlappingActors; TriggerVolume->GetOverlappingActors(overlappingActors); if (overlappingActors.Num() >= 1) { if (AudioComponent != nullptr) { AudioComponent->Play(); } doorOpen = true; opening = true; currentRotation = GetOwner()->GetActorRotation(); } } if (opening) { if (GetOwner()->GetActorRotation().Equals(TargetRotation, 1.0)) { UE_LOG(LogTemp, Display, TEXT("Target Rotation reached")) opening = false; } else { GetOwner()->AddActorLocalRotation(TargetSpeed); } } }