Add Particle Effects and Sound Effect
This commit is contained in:
parent
adef6ecc54
commit
6ad454a881
|
@ -2,6 +2,9 @@
|
|||
|
||||
|
||||
#include "Pickup.h"
|
||||
|
||||
#include <Kismet/GameplayStatics.h>
|
||||
|
||||
#include "PlayerCharacter.h"
|
||||
|
||||
// Sets default values
|
||||
|
@ -50,6 +53,20 @@ void APickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* O
|
|||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue