Skip to content

Instantly share code, notes, and snippets.

@lobotomiac
Created November 11, 2017 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobotomiac/9a33611b2f15fdc4a6f88287aabc8d6d to your computer and use it in GitHub Desktop.
Save lobotomiac/9a33611b2f15fdc4a6f88287aabc8d6d to your computer and use it in GitHub Desktop.
// 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