C++ OnSoundFinished在声音实际结束之前触发

C++ OnSoundFinished在声音实际结束之前触发,c++,audio,unreal-engine4,C++,Audio,Unreal Engine4,我不太明白,所以我在这里问。我正在使用下面发布的函数生成AudioComponent。它附带了10秒的声音提示。然后我在2秒后暂停,并将延迟设置为30秒。然后我想取消我的声音。问题是,我的调度程序在它之前触发,我的声音甚至不能被取消。它被摧毁了吗?有什么办法可以预防吗 UAudioComponent* MyAudioClass::LatentSound2D(UObject* WorldContextObject, struct FLatentActionInfo LatentInfo, clas

我不太明白,所以我在这里问。我正在使用下面发布的函数生成AudioComponent。它附带了10秒的声音提示。然后我在2秒后暂停,并将延迟设置为30秒。然后我想取消我的声音。问题是,我的调度程序在它之前触发,我的声音甚至不能被取消。它被摧毁了吗?有什么办法可以预防吗

UAudioComponent* MyAudioClass::LatentSound2D(UObject* WorldContextObject, struct FLatentActionInfo LatentInfo, class USoundBase* Sound, float VolumeMultiplier, float PitchMultiplier, float StartTime, class USoundConcurrency* ConcurrencySettings, bool bPersistAcrossLevelTransition)
{

    MyAudioClassObject= NewObject<MyAudioClass>();//handle needed to bind delegate
    UAudioComponent* AudioComponent = UGameplayStatics::CreateSound2D(WorldContextObject, Sound, VolumeMultiplier, PitchMultiplier, StartTime);//Create AudioComponent
    MyAudioClassObject->BindDelegate(AudioComponent);//Bind delegate to AudioComponent
    AudioComponent->bAutoDestroy = false;
    AudioComponent->bAllowAnyoneToDestroyMe = false;
    AudioComponent->AddToRoot();
    AudioLatentBind(WorldContextObject, LatentInfo, AudioComponent);    //add latent action for this audio component (wait till it ends)
    return AudioComponent;
}
UAAudioComponent*MyAudioClass::LatentSound2D(UObject*WorldContextObject,struct FlatentationInfo-LatentInfo,class USoundBase*声音,float VolumeMultiplier,float PitchMultiplier,float StartTime,class USoundConcurrency*ConcurrencySettings,bool bPersistAcrossLevelTransition)
{
MyAudioClassObject=NewObject();//绑定委托所需的句柄
UAudioComponent*AudioComponent=UGameplayStatics::CreateSound2D(WorldContextObject、声音、音量倍增器、PitchMultiplier、StartTime);//创建AudioComponent
MyAudioClassObject->BindDelegate(AudioComponent);//将委托绑定到AudioComponent
AudioComponent->bAutoDestroy=false;
AudioComponent->bAllowAnyoneToDestroyMe=false;
AudioComponent->AddToRoot();
AudioLatentBind(WorldContextObject、LatentInfo、AudioComponent);//为此音频组件添加潜在操作(等待其结束)
返回音频组件;
}
我绑定的代理未初始化。如果有什么不清楚的地方,请告诉我。我真的需要帮助:(这是蓝图中的样子


我认为CreateSound2D是用于UI声音的,因此是一个“火与忘”的概念操作。既然您正在创建一个AudioComponent,您不能直接设置声音并播放AudioComponent而不是使用CreateSound2D吗?

您至少可以告诉我们您使用的是哪个库提供了这些类…我们不是读心术的人。我刚刚检查了这个,我的AudioComponent似乎停止了,这就是为什么OnAUdioFinished正在启动。但是我不知道如何阻止这个stop()调用。当然
#包括“MyProjectCodeFunctionLibrary.h”包括“GameFramework/Actor.h”#包括“Object.h”#包括“AudioDevice.h”#包括“ActiveSound.h”#包括“LatentActions.h”#包括“MyAudioClass.generated.h”
这些是我的随附文件。很抱歉,我是新来的,还不知道哪些信息对其他人有价值。只是列出includes并没有告诉我们这是什么库。它的名称是什么?项目网站和文档在哪里?对于函数解释:BindDelegate是自我解释的。它只是绑定到audiofini转到我的AudioComponent。AudioLatentBind正在添加新的潜在acton,它只是等待获得音频已完成的信号,然后允许继续使用exec pin。