Advertisement
Guest User

KillerCube.cpp

a guest
May 13th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
  2.  
  3. #include "MyProject2.h"
  4. #include "KillerCube.h"
  5.  
  6.  
  7. AKillerCube::AKillerCube(const class FPostConstructInitializeProperties& PCIP)
  8.     : Super(PCIP)
  9. {
  10.     // Use a sphere as a simple collision representation
  11.     static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("StaticMesh'/Game/Meshes/TemplateCube_Rounded.TemplateCube_Rounded'"));
  12.  
  13.     MeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp"));
  14.     MeshComp->BodyInstance.SetCollisionProfileName("PhysicsActor");         // Collision profiles are defined in DefaultEngine.ini
  15.     MeshComp->StaticMesh = Mesh.Object;
  16.     MeshComp->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f));
  17.     //MeshComp->SetSimulatePhysics(true);
  18.  
  19.  
  20.     //MeshComp->BodyInstance.bSimulatePhysics(true);
  21.     RootComponent = MeshComp;
  22.  
  23.     for (int i = 0; i < 10; i++)
  24.     {
  25.         MeshArray[i] = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp"));
  26.         //MeshArray.Add(PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp")));
  27.         if (MeshArray[i] != NULL && MeshArray[i]->IsValidLowLevel())
  28.         {
  29.             MeshArray[i]->BodyInstance.SetCollisionProfileName("PhysicsActor");         // Collision profiles are defined in DefaultEngine.ini
  30.             MeshArray[i]->StaticMesh = Mesh.Object;
  31.             MeshArray[i]->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f));
  32.             //MeshArray[i]->SetSimulatePhysics(true);
  33.             MeshArray[i]->SetRelativeLocation(FVector(250*i, 0, 0));
  34.             MeshArray[i]->AttachParent = MeshComp;
  35.         }
  36.     }
  37.    
  38.  
  39.     // Die after 3 seconds by default
  40.     InitialLifeSpan = 0;
  41.     PrimaryActorTick.bCanEverTick = true;
  42.  
  43.     ForcePower = 100.f;
  44. }
  45.  
  46. void AKillerCube::BeginPlay()
  47. {
  48.     Super::BeginPlay();
  49.     if (GEngine)
  50.     {
  51.         GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Blue, TEXT("THIS IS A THING NOW"));
  52.     }
  53. }
  54.  
  55. void AKillerCube::Tick(float DeltaSeconds)
  56. {
  57.     Super::Tick(DeltaSeconds);
  58.     //UE_LOG(LogTemp, Log, TEXT("Ticking!"));
  59.     MeshComp->AddForce(FVector(0, 0, ForcePower));
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement