파티클
/.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item|Effects")
UParticleSystem* PickupParticle;
/.cpp
UParticleSystemComponent* Particle = nullptr;
if (PickupParticle)
{
Particle = UGameplayStatics::SpawnEmitterAtLocation(
GetWorld(),
PickupParticle,
GetActorLocation(),
GetActorRotation(),
true // 파티클 수명이 끝나면 Destroy 처리
);
}
// 2초 후 파티클 제거
if (Particle)
{
FTimerHandle DestroyParticleTimerHandle;
GetWorld()->GetTimerManager().SetTimer(
DestroyParticleTimerHandle,
[Particle]()
{
Particle->DestroyComponent();
},
2.0f,
false);
}
사운드
//.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item|Effects")
USoundBase* PickupSound;
//.cpp
if (PickupSound)
{
UGameplayStatics::PlaySoundAtLocation(
GetWorld(),
PickupSound,
GetActorLocation(),
GetActorRotation()
);
}
느낀 점
언리얼에서는 파티클, 사운드를 위해 개별적으로 호출할 수 있는 메서드가 존재한다는게 놀랍네요.
파티클 출력을 위해 구현한 코드를 보면, ParticleSystem과 ParticleSystemComponent가 있는데 각각의 차이점을 알아봐야 할 것 같습니다 !
'언리얼 엔진 > 스파르타코딩클럽' 카테고리의 다른 글
[언리얼엔진] 4-3. UI 애니메이션 효과 구현 (0) | 2025.02.11 |
---|---|
[언리얼엔진] 4-2. 메인 메뉴 구현 (0) | 2025.02.10 |
[언리얼엔진] 4-1. UI 위젯 설계와 실시간 데이터 연동 (0) | 2025.02.10 |
[언리얼엔진] 3-5. 게임 루프 설계 (0) | 2025.02.07 |
[언리얼엔진] 3-4. 캐릭터 체력 및 점수 시스템 구현 (0) | 2025.02.06 |