Created
July 15, 2017 22:29
-
-
Save ThomasAunvik/88f18d46f08002eb2d517985fda2b6e3 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
// Copyrighted by Thaun Corp © | |
#include "OpenDoor.h" | |
#include "Gameframework/Actor.h" | |
#include "Engine/World.h" | |
// Sets default values for this component's properties | |
UOpenDoor::UOpenDoor() | |
{ | |
// 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 UOpenDoor::BeginPlay() | |
{ | |
Super::BeginPlay(); | |
ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn(); | |
} | |
void UOpenDoor::OpenDoor() | |
{ | |
// Find owning Actor | |
AActor* Owner = GetOwner(); | |
// Create a rotator | |
FRotator NewRotation = FRotator(0.f, 60.f, 0.f); | |
// Set the door rotation | |
Owner->SetActorRotation(NewRotation); | |
} | |
int32 direction = 1; | |
// Called every frame | |
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) | |
{ | |
Super::TickComponent(DeltaTime, TickType, ThisTickFunction); | |
if (PressurePlate->IsOverlappingActor(ActorThatOpens)) { | |
OpenDoor(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment