SHOW:
|
|
- or go back to the newest paste.
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 | - | TempMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp1")); |
23 | + | for (int i = 0; i < 10; i++) |
24 | - | if (TempMesh != NULL && TempMesh->IsValidLowLevel()) |
24 | + | |
25 | TempMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp1")); | |
26 | - | TempMesh->BodyInstance.SetCollisionProfileName("PhysicsActor"); // Collision profiles are defined in DefaultEngine.ini |
26 | + | if (TempMesh != NULL && TempMesh->IsValidLowLevel()) |
27 | - | TempMesh->StaticMesh = Mesh.Object; |
27 | + | { |
28 | - | TempMesh->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f)); |
28 | + | TempMesh->BodyInstance.SetCollisionProfileName("PhysicsActor"); // Collision profiles are defined in DefaultEngine.ini |
29 | - | //TempMesh->SetSimulatePhysics(true); |
29 | + | TempMesh->StaticMesh = Mesh.Object; |
30 | - | TempMesh->SetRelativeLocation(FVector(250, 0, 0)); |
30 | + | TempMesh->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f)); |
31 | - | MeshArray.Add(TempMesh); |
31 | + | //TempMesh->SetSimulatePhysics(true); |
32 | TempMesh->SetRelativeLocation(FVector(250, 0, 0)); | |
33 | MeshArray.Add(TempMesh); | |
34 | } | |
35 | } | |
36 | ||
37 | ||
38 | // Die after 3 seconds by default | |
39 | InitialLifeSpan = 0; | |
40 | PrimaryActorTick.bCanEverTick = true; | |
41 | ||
42 | ForcePower = 100.f; | |
43 | } | |
44 | ||
45 | void AKillerCube::BeginPlay() | |
46 | { | |
47 | Super::BeginPlay(); | |
48 | if (GEngine) | |
49 | { | |
50 | GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Blue, TEXT("THIS IS A THING NOW")); | |
51 | } | |
52 | } | |
53 | ||
54 | void AKillerCube::Tick(float DeltaSeconds) | |
55 | { | |
56 | Super::Tick(DeltaSeconds); | |
57 | //UE_LOG(LogTemp, Log, TEXT("Ticking!")); | |
58 | MeshComp->AddForce(FVector(0, 0, ForcePower)); | |
59 | } |