- Home /
How do you update a scriptable object variable inside of a list?
I'm working on a quest system and I'm using scriptable objects to hold the data. When the quest is given to the player, it gets added to a list of their quests. Say the quest sends the player to kill five mobs. I want to be able to keep track of how many have been killed/collected, etc. inside of the quest list. I can update the SO quest, but when I try to show the same variable in the quest list, it still shows zero mobs killed, zero items collected. It's as if there are two versions of the SO. How can I keep that updated in the list? Thanks in advance!
void AddQuest(QuestClass quest)
{
CurrentQuestList.Add(quest);
print(CurrentQuestList.Count);
ShowCurrentQuests(quest);
}
void ShowCurrentQuests(QuestClass quest)
{
for (int i = 0; i < CurrentQuestList.Count; i++)
{
Instantiate(QuestPrefab,CurrentParent);
}
}
public class KillQuest : QuestClass
{
[System.Serializable]
public class Objectives
{
public string EnemyTarget;
public bool stageComplete;
public int requiredAmount;
public int currentAmount; This variable is not updating inside the quest list, but it is when I look at it in the inspector during play.
}
public List<Objectives> ObjectivesList;
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Getting a reference to a group of ScriptableObjects implemented at runtime? 0 Answers
How to Update ScriptableObject 1 Answer