C++ usage
Review draft. This source page has not completed website editorial and release-specific verification.
Include KnowledgeComponent.h and KnowledgeDirectorTypes.h from the KnowledgeDirectorRuntime module.
#include "KnowledgeComponent.h"#include "KnowledgeDirectorTypes.h"
UKnowledgeComponent* KnowledgeComponent = nullptr; // assign the participant's componentFKnowledgeProvenance Provenance;Provenance.Type = EKnowledgeProvenanceType::Scripted;
const FGameplayTag FactId = FGameplayTag::RequestGameplayTag(TEXT("Knowledge.Fact.Clue.Key"));const FGameplayTag BeliefId = FGameplayTag::RequestGameplayTag(TEXT("Knowledge.Belief.Suspect.Guilty"));
KnowledgeComponent->AcquireFact(FactId, Provenance);KnowledgeComponent->SetBeliefConfidence(BeliefId, 75, Provenance);
int32 Confidence = 0;const bool bHasBelief = KnowledgeComponent->GetBeliefConfidence(BeliefId, Confidence);For a disclosure, create an FKnowledgeItemReference with the exact item type and ID, then call DiscloseKnowledge(Item, RecipientSubjectId). The recipient is a Knowledge.Subject.* identity; no Actor pointer is stored and no recipient acquisition is inferred.
Use the returned FKnowledgeMutationResult to distinguish Changed, NoChange, Rejected, and invalid input statuses. The component’s OnKnowledgeChangedNative and Blueprint OnKnowledgeChanged notifications describe committed changes.
The editor-only native seam is ApplyEditorDebugOverride(const FKnowledgeEditorDebugRequest&) with RestoreEditorDebugBaseline(). These functions are available only under WITH_EDITOR, are not Blueprint or shipping APIs, and return FKnowledgeDebugMutationResult. The debug overlay changes resolved queries without changing canonical persistence; it sends the editor-only debug notification rather than fabricating normal domain events.