【UE4 C++】播放声音、特效

播放声音

  • 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*

posted @ 2021-05-05 16:34  砥才人  阅读(1566)  评论(0编辑  收藏  举报