Created
November 11, 2017 13:59
-
-
Save lobotomiac/9a33611b2f15fdc4a6f88287aabc8d6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// nemozenitkodirnitovo | |
#include "CloseDoor.h" | |
#include "Engine/World.h" | |
#include "Gameframework/Actor.h" | |
// Sets default values for this component's properties | |
UCloseDoor::UCloseDoor() | |
{ | |
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features | |
// off to improve performance if you don't need them. | |
PrimaryComponentTick.bCanEverTick = true; | |
// ... | |
} | |
// Called when the game starts | |
void UCloseDoor::BeginPlay() | |
{ | |
Super::BeginPlay(); | |
ActorThatCloses = GetWorld()->GetFirstPlayerController()->GetPawn(); | |
} | |
void UCloseDoor() | |
{ | |
// Get Owning actor | |
AActor *Owner = GetOwner(); | |
//set new rotator | |
FRotator NewRotation = FRotator(0.f, 0.f, 0.f); | |
// rotate door | |
Owner->SetActorRotation(NewRotation); | |
} | |
// Called every frame | |
void UCloseDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | |
{ | |
Super::TickComponent(DeltaTime, TickType, ThisTickFunction); | |
if (PressurePlate && PressurePlate->IsOverlappingActor(ActorThatCloses)) | |
{ | |
CloseDoor(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment