From 6ad454a881d7bb5d33b1a34780ca2aaa6eb2cc20 Mon Sep 17 00:00:00 2001 From: Louis Hobbs Date: Sun, 25 Jun 2023 01:17:36 +0100 Subject: [PATCH] Add Particle Effects and Sound Effect --- Source/Nakatomi/Pickup.cpp | 17 +++++++++++++++++ Source/Nakatomi/Pickup.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/Source/Nakatomi/Pickup.cpp b/Source/Nakatomi/Pickup.cpp index 522c309..0c8469b 100644 --- a/Source/Nakatomi/Pickup.cpp +++ b/Source/Nakatomi/Pickup.cpp @@ -2,6 +2,9 @@ #include "Pickup.h" + +#include + #include "PlayerCharacter.h" // Sets default values @@ -50,6 +53,20 @@ void APickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* O { if (Cast(OtherActor)) { + if (FireSound) + { + UGameplayStatics::PlaySoundAtLocation(this, FireSound, this->ActorToWorld().GetLocation()); + } + + if (ParticleSystem) + { + UGameplayStatics::SpawnEmitterAtLocation(this, + ParticleSystem, + this->ActorToWorld().GetLocation(), + FRotator::ZeroRotator, + true); + } + this->Destroy(); } } diff --git a/Source/Nakatomi/Pickup.h b/Source/Nakatomi/Pickup.h index a9135dc..31302c6 100644 --- a/Source/Nakatomi/Pickup.h +++ b/Source/Nakatomi/Pickup.h @@ -25,6 +25,12 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) FColor LightColor = FColor::White; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + USoundBase* FireSound; + + UPROPERTY(EditDefaultsOnly) + UParticleSystem* ParticleSystem; + private: UPROPERTY() USphereComponent* SphereComponent;