【UE4 C++】播放声音、特效
阅读原文时间:2023年07月10日阅读:1

播放声音

  • PlaySoundAtLocation()

    USoundCue* HitSound = LoadObject<USoundCue>(this, TEXT("SoundCue'/Game/Demo_Drone/Sound/explore_Cue.explore_Cue'"));
    if (HitSound)
    {
    UGameplayStatics::PlaySoundAtLocation(this, HitSound,SweepResult.Location);
    }
  • PlaySound2D()

    UGameplayStatics::PlaySound2D(GetWorld(), HitSound)
  • 其他

    • SpawnSound2D() 返回 UAudioComponent*
    • CreateSound2D() 返回 UAudioComponent*
    • SpawnSoundAtLocation() 返回 UAudioComponent*
    • SpawnSoundAttached() 返回 UAudioComponent*

播放特效

  • SpawnEmitterAtLocation() 返回 UParticleSystemComponent*

    FString exploreParticlePath = TEXT("ParticleSystem'/Game/InfinityBladeEffects/Effects/FX_Monsters/FX_Monster_Chicken/P_Proj_Chicken_Imp_Explo_01.P_Proj_Chicken_Imp_Explo_01'");
    UParticleSystem* exploreFX = LoadObject<UParticleSystem>(this, *exploreParticlePath);
    if (exploreFX)
    {
        UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), exploreFX, FTransform(UKismetMathLibrary::MakeRotFromX(SweepResult.Normal), SweepResult.Location, FVector::OneVector));
    }
  • SpawnEmitterAttached() 返回 UParticleSystemComponent*

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章