Broadcasting and Subscribe in C++¶
C++ code¶
Add to QuestMarker.h
protected:
virtual void BeginPlay() override;
private:
void QuestUpdate(int32 Index);
Added to QuestMarker.cpp
void AQuestMarker::BeginPlay()
{
GetQuestManager()->CompletedQuest.AddDynamic(this, &AQuestMarker::QuestUpdate);
RefreshVisibility();
}
void AQuestMarker::QuestUpdate(int32 Index)
{
RefreshVisibility();
}
Add one line at the bottom of QuestManager.cpp -> AQuestManager::CompleteQuest_Implementation
CompletedQuest.Broadcast(QuestIndex);
Blueprint¶
We can not delete the event graph for QuestMarker and QuestManager