Add Particle Effects and Sound Effect
This commit is contained in:
		
							parent
							
								
									adef6ecc54
								
							
						
					
					
						commit
						6ad454a881
					
				| @ -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(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -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; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user