1. AudioComponet 에 등록하고 재생하는 방법

2. UGamePlayStatic::PlaySound 로 재생하는 방법

3. Cue 파일 재생 방법

4. wav 파일  재생 방법

 


1. AudioComponet 에 등록하고 재생하는 방법

//h
UAudioComponent* AudioComponent;

USoundCue* Fire_Sound;

//cpp
{
  AudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("SOUND"));;
  AudioComponent->SetupAttachment(Mesh);

  static ConstructorHelpers::FObjectFinder<USoundBase> FireSound(TEXT("SoundWave'/Game/_SOUND/Pistol_FIRE.Pistol_FIRE'"));
  if (FireSound.Succeeded())
  {
	Fire_Sound = FireSound.Object;
  }
}


{
	if (AudioComponent->IsValidLowLevelFast()) 
   {
		AudioComponent->SetSound(Fire_Sound);
   }
}


{
  AudioComponent->Play();
}

 

소리 액터


플레이어 안태 소리에 따른 감쇠 없이 재생이 된다.


※ 본인이 AudioComponet을 이용하여 감쇠하는 방법을 못찾은 거 일수도 있음


2. UGamePlayStatics::PlaySound 로 재생하는 방법


UGameplayStatics::PlaySoundAtLocation(this, Fire_Sound, GetActorLocation());
static void PlaySoundAtLocation(const UObject* WorldContextObject, USoundBase* Sound, 
FVector Location, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, 
float StartTime = 0.f, class USoundAttenuation* AttenuationSettings = nullptr, USoundConcurrency* ConcurrencySettings = nullptr)
{
  PlaySoundAtLocation(WorldContextObject, Sound, Location, FRotator::ZeroRotator, VolumeMultiplier, PitchMultiplier, StartTime, AttenuationSettings, ConcurrencySettings);
}

 

AudioComponet  필요 없이,  UGameplayStatics:: 이용해서 재생을 하면 된다.

UGameplayStatics 이용하면 USoundAttenuation을 이용해서 소리 기하감쇠 넣을 수 있는 함수까지 사용 할수 가 있다.

코드로 만들 경우, 2 물체 거리를 체크를 한다음. 소리 크키를 보간해서 재생하면 될거 같다

 

거리에 따른 소리감쇠


총소리도 위처럼 기하감쇠를 적용예정


3. Cue 파일 재생 방법

 

 

Soundcue - Wave파일 연결시 오류



Soundcue로 만들면, 파일 확장자도 cue 여야 소리가 재생된다


4. wav 파일  재생 방법


 SoundBase 로 만들로 정의 하고 실행을 하니 Wave 확장자도 소리가 재생된다.

USoundWave을 이용해도 Wave 확장자가 재생된다.



총소리는 기하 감쇠를 적용하기 위해서 일단 UPlayStatuc을 이용해서 재생을 하게 함


소리는 Fire, Reload, EmptyFire 을 적용함

발사 사운드

 

'Unreal > Game 2 ' 카테고리의 다른 글

8. AimOffSet 방법 2가지  (0) 2019.06.24
7.3 코드 수정  (0) 2019.06.23
7.1 발사 이펙트 + 사운드 cue,wav  (0) 2019.06.21
7. 탄 생성, 발사, 재장전  (0) 2019.06.20
6. 무기 생성 및 소켓 장착  (0) 2019.06.19

+ Recent posts