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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM