How to Use in C++
Blueprints logic is the same as C++ and function names are the same, so for this I will just show you how to access the game instance subsystem used for generating, assigning callbacks, and adding a AC_GPTDialogue Component to your actor class.
Feel free to copy the code below.
Adding the Component(Header File)
class UAC_GPTDialogue;
UCLASS()
class GPTDIALOGUE_API AGPTDialogueActor : public AActor
{
GENERATED_BODY()
public:
AGPTDialogueActor();
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UAC_GPTDialogue* GPTDialogueComponent;
};Adding the Component(CPP file)
Accessing the Component for its functions
Generating Text and Voice Dialogue in C++
for this we will use a lambda as the callbacks for simplicity sake, but you can link it to other functions if you wish.
That is it, you should now be able to generate text and voice dialogue in c++, you will edit the GPT Context in the editor under the details panel like with the blueprints version.
Last updated