Giving Quest via Code does not reset the Time Accepted count when game is restart?
Posted: Mon Mar 11, 2024 1:58 pm
Hi, I have come across a weird behaviour from Quest Machine.
Basically I have a Quest Giver Manager, that gives the player a quest manually via code. It only has the Quest Giver component, and my custom Quest Giver Manager script something like this:
When I start the game in unity and run the Method GiveQuest(), it works for the first time.
But, when I stop and play the game again, the quest is automatically deleted from the QuestGiver's quest list. I found out that this is because the timesAccepted of the Quest is saved in the system and it will only work again if increase the "Max Times" of the quest to a high amount, OR I reset the timesAccepted of the quest manually like this:
Is it intended to be working like this, as I figure the timesAccepted of a quest should be save manually in the save file?
Basically I have a Quest Giver Manager, that gives the player a quest manually via code. It only has the Quest Giver component, and my custom Quest Giver Manager script something like this:
Code: Select all
using PixelCrushers.QuestMachine;
using Sirenix.OdinInspector;
using UnityEngine;
public class QuestGiverManager : MonoBehaviour
{
private QuestGiver _questGiver;
[SerializeField] private string _questerIdToGive = "Player";
[SerializeField] private Quest _questToAdd;
[Button]
private void GiveQuest()
{
_questGiver = GetComponent<QuestGiver>();
_questGiver.GiveQuestToQuester(_questToAdd, _questerIdToGive);
}
}
But, when I stop and play the game again, the quest is automatically deleted from the QuestGiver's quest list. I found out that this is because the timesAccepted of the Quest is saved in the system and it will only work again if increase the "Max Times" of the quest to a high amount, OR I reset the timesAccepted of the quest manually like this:
Code: Select all
private void OnEnable()
{
_questToAdd.timesAccepted = 0;
}