How to set Debug Actor in Gameplay Debugger?

I was able to get the answer I needed, thanks to the suggestion made by Raptagon Studios. Here is what I did:

  1. Created a new gameplay debugger extension class and binded enter to it with:

//This is required so that the extension has the appropriate key used to handle it.
const FGameplayDebuggerInputHandlerConfig KeyConfig(TEXT(“Enter”), EKeys::Enter.GetFName());
bHasInputBinding = BindKeyPress(KeyConfig, this, &FHeroExtension_CharacterSelection::TogglePlayerSelect);

  1. In the extension class you have access to AGameplayDebuggerCategoryReplicator with the GetReplicator() function.

AGameplayDebuggerCategoryReplicator* Replicator = GetReplicator();

  1. You can then use the replicator to access both GetDebugActor() and SetDebugActor()

This is the final segment of code I used:

void FHeroExtension_CharacterSelection::TogglePlayerSelect()
{
	//Gets Replicator and updates the current debug actor based on whether there is already a valid selected player or not.
	AGameplayDebuggerCategoryReplicator* Replicator = GetReplicator();
	if (Replicator)
	{
		class AHeroCharacter* Character = SelectedPlayer.Get();
		class AActor* SelectedActor = InitialActor.Get();
		if (Character)
		{
			Replicator->SetDebugActor(SelectedActor, false);
			SelectedPlayer = nullptr;
		}
		else
		{
			APlayerController* OwnerPC = GetPlayerController();
			if (OwnerPC)
			{
				Character = Cast<AHeroCharacter>(OwnerPC->GetCharacter());
				SelectedPlayer = Character;
				Replicator->SetDebugActor(Character, false);
			}
		}
	}

	bIsCachedDescriptionValid = false;
}

I really hope this helps somebody in the future :smiley: Thanks again for the help.

3 Likes