Add Particle Effects and Sound Effect

This commit is contained in:
Louis Hobbs 2023-06-25 01:17:36 +01:00
parent adef6ecc54
commit 6ad454a881
2 changed files with 23 additions and 0 deletions

View File

@ -2,6 +2,9 @@
#include "Pickup.h" #include "Pickup.h"
#include <Kismet/GameplayStatics.h>
#include "PlayerCharacter.h" #include "PlayerCharacter.h"
// Sets default values // Sets default values
@ -50,6 +53,20 @@ void APickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* O
{ {
if (Cast<APlayerCharacter>(OtherActor)) if (Cast<APlayerCharacter>(OtherActor))
{ {
if (FireSound)
{
UGameplayStatics::PlaySoundAtLocation(this, FireSound, this->ActorToWorld().GetLocation());
}
if (ParticleSystem)
{
UGameplayStatics::SpawnEmitterAtLocation(this,
ParticleSystem,
this->ActorToWorld().GetLocation(),
FRotator::ZeroRotator,
true);
}
this->Destroy(); this->Destroy();
} }
} }

View File

@ -25,6 +25,12 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
FColor LightColor = FColor::White; FColor LightColor = FColor::White;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
USoundBase* FireSound;
UPROPERTY(EditDefaultsOnly)
UParticleSystem* ParticleSystem;
private: private:
UPROPERTY() UPROPERTY()
USphereComponent* SphereComponent; USphereComponent* SphereComponent;