Guest User

Untitled

a guest
Jan 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. // Copyrights Tadeusz Hyży <tadeuszhyzy@gmail.com>
  2.  
  3. #include "BuildingEscape.h"
  4. #include "OpenDoor.h"
  5.  
  6. UOpenDoor::UOpenDoor()
  7. {
  8.     PrimaryComponentTick.bCanEverTick = true;
  9.     MaxOpenAngle = 90.f;
  10.     MinOpenAngle = 0.f;
  11. }
  12.  
  13. void UOpenDoor::BeginPlay()
  14. {
  15.     Super::BeginPlay();
  16.     ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
  17.     Owner = GetOwner();
  18. }
  19.  
  20. void UOpenDoor::OpenDoor()
  21. {
  22.     float OpenAngle = Owner->GetActorRotation().Yaw;
  23.     if (OpenAngle < MaxOpenAngle)
  24.     {
  25.         Owner->SetActorRotation(FRotator(0.f, (OpenAngle + 1.f), 0.f));
  26.     }
  27. }
  28.  
  29. void UOpenDoor::CloseDoor()
  30. {
  31.     float OpenAngle = Owner->GetActorRotation().Yaw;
  32.     if (OpenAngle > MinOpenAngle)
  33.     {
  34.         Owner->SetActorRotation(FRotator(0.f, (OpenAngle - 1.f), 0.f));
  35.     }
  36. }
  37.  
  38. void UOpenDoor::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
  39. {
  40.     Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
  41.  
  42.     if (PressurePlate->IsOverlappingActor(ActorThatOpens))
  43.     {
  44.         OpenDoor();
  45.     }
  46.     else
  47.     {
  48.         CloseDoor();
  49.     }
  50. }
Add Comment
Please, Sign In to add comment