[SOLVED]KeyNotFoundException
Posted: Thu Feb 06, 2020 10:09 am
Hi,
I keep getting an error on one Quest Giver: KeyNotFoundException: the given key was not present in the dictionary. If I disable the Quest Giver it goes away.
I'm also getting a warning before it, probably related to a script that is trying to access the state of a quest: "GetQuestState(rescueEzmore): Could find a quest with ID 'rescueEzmore'
Here's the code that I wrote for checking quest state:
Is the warning related to the key error? Do I need to check if a quest state is null before I check if it's successful?
Thank you.
I keep getting an error on one Quest Giver: KeyNotFoundException: the given key was not present in the dictionary. If I disable the Quest Giver it goes away.
I'm also getting a warning before it, probably related to a script that is trying to access the state of a quest: "GetQuestState(rescueEzmore): Could find a quest with ID 'rescueEzmore'
Here's the code that I wrote for checking quest state:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.QuestMachine;
public class CheckQuestState : MonoBehaviour
{
[SerializeField] GameObject prefabOfNPC;
void Start()
{
StartCoroutine(ActivateNPC(.5f));
}
IEnumerator ActivateNPC(float waitTime)
{
yield return new WaitForSeconds(waitTime);
//static QuestState PixelCrushers.QuestMachine.QuestMachine.GetQuestState(string questID, string questerID = null);
if (QuestMachine.GetQuestState("rescueEzmore") == QuestState.Successful)
{
print("my quest state is successful");
prefabOfNPC.SetActive(true);
}
}
}
Thank you.