Add the CharacterQuestSetup script below to the GameObject:
CharacterQuestSetup.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CharacterQuestSetup : MonoBehaviour
{
[QuestPopup] public string quest;
public Transform inactiveLocation;
public Transform activeLocation;
public Transform completedLocation;
private void Start()
{
switch (QuestLog.GetQuestState(quest))
{
case QuestState.Unassigned:
GotoLocation(inactiveLocation); break;
case QuestState.Active:
GotoLocation(activeLocation); break;
case QuestState.Success:
case QuestState.Failure:
GotoLocation(completedLocation); break;
default:
GotoLocation(null); break;
}
}
private void GotoLocation(Transform location)
{
if (location == null)
{
gameObject.SetActive(false);
}
else
{
transform.SetPositionAndRotation(location.position, location.rotation);
}
}
}