diff --git a/Source/Nakatomi/Destructable.cpp b/Source/Nakatomi/Destructable.cpp new file mode 100644 index 0000000..f7bfc14 --- /dev/null +++ b/Source/Nakatomi/Destructable.cpp @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Destructable.h" +#include + +// Sets default values +ADestructable::ADestructable() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = false; + + StaticMesh = CreateDefaultSubobject(TEXT("StaticMeshComponent")); + + this->Tags.Add(FName("Destructable")); +} + +// Called when the game starts or when spawned +void ADestructable::BeginPlay() +{ + Super::BeginPlay(); + + if (!this->ActorHasTag(FName("Destructable"))) + { + this->Tags.Add(FName("Destructable")); + } +} + +void ADestructable::Destruct() +{ + // TODO: Add some more logic here + + UGameplayStatics::SpawnEmitterAtLocation(this, ParticleEffect, this->ActorToWorld().GetLocation(), FRotator::ZeroRotator, true); + Destroy(); +} diff --git a/Source/Nakatomi/Destructable.h b/Source/Nakatomi/Destructable.h new file mode 100644 index 0000000..b055aa0 --- /dev/null +++ b/Source/Nakatomi/Destructable.h @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "Destructable.generated.h" + +UCLASS() +class NAKATOMI_API ADestructable : public AActor +{ + GENERATED_BODY() + +public: + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + class UParticleSystem* ParticleEffect; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + class UStaticMeshComponent* StaticMesh; + + // Sets default values for this actor's properties + ADestructable(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + + void Destruct(); + +};