이번 글은 저번 퀘스트 시스템 글에서 이어집니다
2025.12.19 - [Unreal 프로젝트 다이어리/두번째 프로젝트] - Unreal - 퀘스트 시스템
Unreal - 퀘스트 시스템
구현내용플레이어가 NPC 에게 퀘스트를 의뢰하고, 해당 퀘스트를 완료하면보상을 획득하는 NPC 의뢰 기반으로 퀘스트 수락 - 진행 - 완료 - 보상 까지이어지는 퀘스트 시스템을 구현하였습니다.
lucodev.tistory.com
미리보기

구현내용
퀘스트 시스템의 디테일을 추가 구현하였습니다
구현된 내용은 이와 같습니다
- 플레이어가 진행할 수 있는 퀘스트가 있으면 Npc 머리위에 ? 를 표기합니다
- 플레이어가 완료 할 수 있는 퀘스트가 있으면 Npc 머리위에 ! 를 표기합니다
- 배달 퀘스트의 로직을 구현
구현
추가된 머리위의 퀘스트 마커 업데이트 내용
모든 Npc의 부모 객체인 BasNpc에 퀘스트 마커 업데이트 함수 제작
void ABasicNpc::UpdateQuestMarker(bool bShowAccept, bool bShowComplete)
{
if (!questMarkerNa)
return;
questMarkerNa->Deactivate();
questMarkerNa->SetAsset(nullptr);
if (bShowAccept && questAcceptNiagara)
{
questMarkerNa->SetAsset(questAcceptNiagara);
questMarkerNa->Activate(true);
}
else if (bShowComplete && questCompleteNiagara)
{
questMarkerNa->SetAsset(questCompleteNiagara);
questMarkerNa->Activate(true);
}
}
QuestComponent 수정
UpdateNpcQuestMarkers함수 추가
void UQuestComponent::UpdateNpcQuestMarkers()
{
for (TActorIterator<ABasicNpc> it(GetWorld()); it; ++it)
{
ABasicNpc* npc = *it;
if (!npc)
continue;
int32 acceptableQuestCount = 0;
int32 completableQuestCount = 0;
if (npc->IsA(AShopQuestNPC::StaticClass()))
{
for (auto& questPair : questManager->GetAllQuests())
{
const FQuestData& questData = questPair.Value;
if (!activeQuest.Contains(questData.QuestID))
acceptableQuestCount++;
}
for (auto& questPair : activeQuest)
{
const FQuestProgress& progress = questPair.Value;
const FQuestData* questData = questManager->GetQuestData(progress.progressQuestID);
if (questData && progress.bCompleted)
completableQuestCount++;
}
}
else if (npc->IsA(ANpcCiel::StaticClass()))
{
// 기본값 숨김
acceptableQuestCount = 0;
completableQuestCount = 0;
const FQuestProgress* progress = activeQuest.Find(3);
if (progress && !progress->bCompleted)
completableQuestCount = 1;
npc->UpdateQuestMarker(false, completableQuestCount > 0);
continue;
}
if (completableQuestCount > 0)
npc->UpdateQuestMarker(false, true); // !
else if (acceptableQuestCount > 0)
npc->UpdateQuestMarker(true, false); // ?
else
npc->UpdateQuestMarker(false, false); // 숨김
}
}
배달 로직 구현
void UQuestComponent::OnDeliverItem(int32 itemID, int32 npcID)
{
EachActiveQuest([this, itemID, npcID](FQuestProgress& progress, const FQuestData* questData)
{
if (questData->questType != EQuestType::Deliver)
return false;
if (questData->targetID != itemID)
return false;
if (questData->targetNpcID != 0 && questData->targetNpcID != npcID)
return false;
progress.progressCurrentCount++;
if (progress.progressCurrentCount >= questData->targetCount)
{
progress.bCompleted = true;
if (progress.progressQuestID == 3)
guideManager->EndSingleTarget("NPC_1");
}
return true;
});
UpdateNpcQuestMarkers();
}
결과
받을수 있는 퀘스트가 존재하면 머리위에 ? 로 표시됩니다

퀘스트를 완료시 ? 에서 ! 로 변경됩니다


배달 시스템은 도저히 Gif로 한번에 다 담을수 없어서 영상으로 설명드리겠습니다
영상
이걸 하나를 구현하기위에 수많은 클래스 작업이 있었네요..
월드마커가 꽤나 이쁘게 구현된거같습니다 :)
'Unreal 프로젝트 다이어리 > 두번째 프로젝트' 카테고리의 다른 글
| Unreal - 버프창 (0) | 2025.12.27 |
|---|---|
| Unreal - 퀵슬롯 (0) | 2025.12.27 |
| Unreal - 가이드 마커 (0) | 2025.12.22 |
| Unreal - 대화 Npc (0) | 2025.12.22 |
| Unreal - 퀘스트 시스템 (0) | 2025.12.19 |