(39) 's Extra Blueprint Nodes for You as a Plugin, No C++ Required!

's Victory Subtitle System, BP Access for Subtitles of SoundWaves in SoundCues

Dear Community,

It has come to my attention that there is no way to easily access the subtitles that are inside of SoundWaves which are played in SoundCues via WavePlayer.

For any AAA or indie project that wants to use UE4’s Subtitle system is actually a rather essential missing element of UE4 Blueprints!

I have developed a simple system to intercept the C++ delegate for subtitles played by UE4’s C++ sound system.

I have exposed for you in Blueprints!

Now you can use the subtitle data stored in Dialogue or SoundWaves easily in BP, at the the sound is being played!

I had to use my VictoryPC class to do , because the C++ Delegate must be binded to a UObject, which prevents me from using just a static BP node.


**Usage**

**So to use my Victory Subtitle System:**

1. In a C++ project you are best suited to extract my code form VictoryPC and add to your appropriate UObject or Actor class

2. In a BP project you should have your Player Controller extend my VictoryPC class which comes with my Victory Plugin.

3. See pictures for the rest!

FAQ

When is Speech Finished?

Please note there is an easy way to know when the sound is finished by binding an event to the return value of my BP ndoe!

Sound Duration?

The total sound duration is called Cue Duration off of my Subtitle Event node.

Multiple Subtitles With Stamps for 1 Sound?

My system supports as many subtitles as you entered, and via my BP setup you can display the stamp of each subtitle, accessing that info in order to visually display the subtitle at the right .

You also get the total length of the speech sound being played.

Any Kind of sound?

You can play any sound you want with my node and if it has UE4 subtitles set via the appropriate asset (SoundWave or Dialogue) my OnVictorySubtitlesQueued Event will be called!


**C++ Code**

Here is the C++ code if you wish to extract it easily into your own project.

 is  my own code for you, at no cost!



```


//Exposing the UE4 Subtitle system for Solus
// <3
USTRUCT(BlueprintType)
struct **FVictorySubtitleCue**
{
	GENERATED_USTRUCT_BODY()

	/** The text to appear in the subtitle. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SubtitleCue)
	FText SubtitleText;

	/** The  at which the subtitle is to be displayed, in seconds relative to the beginning of the line. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SubtitleCue)
	float ;

	FVictorySubtitleCue()
		: (0)
	{ } 
	FVictorySubtitleCue(const FText& InText, float InTime)
	: SubtitleText(InText)
	, (InTime)
	{}
};


UCLASS()
class VICTORYBPLIBRARY_API AVictoryPC : public APlayerController
{
	GENERATED_BODY()

public:
	AVictoryPC(const FObjectInitializer& ObjectInitializer);
	
	/** 
	* When the sound is played OnVictorySubtitlesQueued will be called with the subtitles!
	* You can bind an event off of the audio component for OnAudioFinished to know hwen the sound is ! 
	*/ 
	UFUNCTION(Category="Victory Subtitles", BlueprintCallable, BlueprintCosmetic, meta=( UnsafeDuringActorConstruction = "true", Keywords = "play" ))
	UAudioComponent* **VictoryPlaySpeechSound**(class USoundBase* Sound, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f);
	
	UFUNCTION(Category="Victory Subtitles", BlueprintImplementableEvent)
	void **OnVictorySubtitlesQueued**(const TArray<struct FVictorySubtitleCue>& VictorySubtitles, float CueDuration);
	
	UFUNCTION()
	void **Subtitles_CPPDelegate**(const TArray<struct FSubtitleCue>& VictorySubtitles, float CueDuration);
};


```





```


/*

	By

*/

#include "VictoryBPLibraryPrivatePCH.h"
#include "VictoryPC.h"
 
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"

UAudioComponent* AVictoryPC::**VictoryPlaySpeechSound**(
	USoundBase* Sound
	,float VolumeMultiplier
	,float PitchMultiplier
	, float StartTime)
{

	UAudioComponent* Audio = UGameplayStatics::SpawnSound2D(,Sound,VolumeMultiplier,PitchMultiplier,StartTime);
	if(Audio)
	{
		//Subtitle Delegate for You!
		//		<3
		Audio->OnQueueSubtitles.BindDynamic(, &AVictoryPC::Subtitles_CPPDelegate);
	}      
	
	/*
		Note that the OnAudioFinished is BP assignable off of return of  node!
		
		//called when we finish playing audio, either because it played to completion or because a Stop() call turned it off early
		UPROPERTY(BlueprintAssignable)
		FOnAudioFinished OnAudioFinished;
	*/
	
	return Audio;
}
 
void AVictoryPC::**Subtitles_CPPDelegate**(const TArray<struct FSubtitleCue>& Subtitles, float CueDuration)
{
	TArray<FVictorySubtitleCue> VictorySubtitles; 
	for(const FSubtitleCue& Each : Subtitles)
	{
		VictorySubtitles.Add(FVictorySubtitleCue(Each.Text,Each.));
	} 
	  
	**OnVictorySubtitlesQueued**(VictorySubtitles,CueDuration);
}


```



**Latest plugin download on the UE4 Wiki: (7.16 mb) **

Plugin Release Dates and UE4 Engine Versions


**Donations**

Donations can be sent to me via:
http://lightningfitness.org/donate/

Enjoy!

:)