1 // Fill out your copyright notice in the Description page of Project Settings.
3 #include "BuildingEscape.h"
7 // Sets default values for this component's properties
10 // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
11 // off to improve performance if you don't need them.
12 bWantsBeginPlay
= true;
13 PrimaryComponentTick
.bCanEverTick
= true;
19 // Called when the game starts
20 void UOpenDoor::BeginPlay()
24 ActorThatOpens
= GetWorld()->GetFirstPlayerController()->GetPawn();
28 void UOpenDoor::OpenDoor()
30 Owner
->SetActorRotation(FRotator(0.0f
, OpenAngle
, 0.0f
));
33 void UOpenDoor::CloseDoor()
35 Owner
->SetActorRotation(FRotator(0.0f
, 0.0f
, 0.0f
));
39 void UOpenDoor::TickComponent( float DeltaTime
, ELevelTick TickType
, FActorComponentTickFunction
* ThisTickFunction
)
41 Super::TickComponent( DeltaTime
, TickType
, ThisTickFunction
);
43 // Poll the TriggerVolume
44 // If the ActorThatOpens is in the volume
45 if (PressurePlate
->IsOverlappingActor(ActorThatOpens
))
48 LastDoorOpenTime
= GetWorld()->GetTimeSeconds();
51 // Check if it's time to close the door
52 if (GetWorld()->GetTimeSeconds() - LastDoorOpenTime
> DoorCloseDelay
)