Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
- #include "MyProject2.h"
- #include "KillerCube.h"
- AKillerCube::AKillerCube(const class FPostConstructInitializeProperties& PCIP)
- : Super(PCIP)
- {
- // Use a sphere as a simple collision representation
- static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("StaticMesh'/Game/Meshes/TemplateCube_Rounded.TemplateCube_Rounded'"));
- MeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp"));
- MeshComp->BodyInstance.SetCollisionProfileName("PhysicsActor"); // Collision profiles are defined in DefaultEngine.ini
- MeshComp->StaticMesh = Mesh.Object;
- MeshComp->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f));
- //MeshComp->SetSimulatePhysics(true);
- //MeshComp->BodyInstance.bSimulatePhysics(true);
- RootComponent = MeshComp;
- for (int i = 0; i < 10; i++)
- {
- MeshArray[i] = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp"));
- //MeshArray.Add(PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp")));
- if (MeshArray[i] != NULL && MeshArray[i]->IsValidLowLevel())
- {
- MeshArray[i]->BodyInstance.SetCollisionProfileName("PhysicsActor"); // Collision profiles are defined in DefaultEngine.ini
- MeshArray[i]->StaticMesh = Mesh.Object;
- MeshArray[i]->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f));
- //MeshArray[i]->SetSimulatePhysics(true);
- MeshArray[i]->SetRelativeLocation(FVector(250*i, 0, 0));
- MeshArray[i]->AttachParent = MeshComp;
- }
- }
- // Die after 3 seconds by default
- InitialLifeSpan = 0;
- PrimaryActorTick.bCanEverTick = true;
- ForcePower = 100.f;
- }
- void AKillerCube::BeginPlay()
- {
- Super::BeginPlay();
- if (GEngine)
- {
- GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Blue, TEXT("THIS IS A THING NOW"));
- }
- }
- void AKillerCube::Tick(float DeltaSeconds)
- {
- Super::Tick(DeltaSeconds);
- //UE_LOG(LogTemp, Log, TEXT("Ticking!"));
- MeshComp->AddForce(FVector(0, 0, ForcePower));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement