Advertisement
Guest User

pushDoor CPP

a guest
May 13th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #include "theWolf.h"
  4. #include "PushDoor.h"
  5. #include "Engine.h"
  6.  
  7.  
  8. // Sets default values
  9. APushDoor::APushDoor()
  10. {
  11.     // define the mesh.  
  12.     static ConstructorHelpers::FObjectFinder<UStaticMesh>
  13.         DoorMesh(TEXT("/Game/SM_Door2.SM_Door2"));
  14.     // Create mesh component for the Asteroid.  
  15.     StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("door"));
  16.     // Here we insert a mesh into the mesh we created.  
  17.     StaticMeshComponent->SetStaticMesh(DoorMesh.Object);
  18.     // Set the root component to the mesh. IS THIS NEEDED. I AM SETTING IT BELOW.  
  19.     StaticMeshComponent->AttachTo(RootComponent);  
  20.  
  21.     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
  22.     PrimaryActorTick.bCanEverTick = true;
  23.  
  24.     doorHit = false;
  25.  
  26. }
  27.  
  28. // Called when the game starts or when spawned
  29. void APushDoor::BeginPlay()
  30. {
  31.     Super::BeginPlay();
  32.  
  33.     if (GEngine)
  34.     {
  35.         GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("V1.06"));
  36.     }
  37.    
  38. }
  39.  
  40. // Called every frame
  41. void APushDoor::Tick( float DeltaTime )
  42. {
  43.     Super::Tick( DeltaTime );
  44.     if (doorHit == true ){
  45.         FRotator DoorRotation = GetActorRotation();
  46.  
  47.         DoorRotation.Yaw += 1;
  48.  
  49.         SetActorRotation(DoorRotation);
  50.        
  51.         //doorOpen.Yaw = doorOpen.Yaw + 1;
  52.     }
  53.  
  54. }
  55.  
  56. void APushDoor::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
  57. {  
  58.     if (OtherActor->GetName().Contains(TEXT("character"), ESearchCase::IgnoreCase, ESearchDir::FromStart))
  59.     {
  60.         if (GEngine)
  61.         {
  62.             GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("shot hit asteroid"));
  63.         }
  64.     }
  65.    
  66.     doorHit = true;
  67.         if (GEngine)
  68.         {
  69.             GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("door hit"));
  70.         }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement