[Resolved] Set Quest Journal ID's at runtime
Posted: Sun Sep 29, 2019 6:43 am
Hi all,
I'm working on a project where we are using Questmachine, LoveHate and the Dialogue System together.
We are looking to generate a number of NPC's with quest journals at runtime and then have them run around completing quests that will be generated for them (whilst having opinions about the other characters thanks to LoveHate).
As part of character generation, I'm wanting to access the "Quest Journal" component as each character is created and set a unique value for "ID" and "Display Name".
I'm struggling to set the "ID" field in the quest journal (although I suspect that I'm overlooking something obvious ).
Here is the current code from the script in question as it stands:
I've attempted to set the id variable using a variety of methods before this but haven't figured out a way yet.
Any advice would be appreciated.
Biscuit
I'm working on a project where we are using Questmachine, LoveHate and the Dialogue System together.
We are looking to generate a number of NPC's with quest journals at runtime and then have them run around completing quests that will be generated for them (whilst having opinions about the other characters thanks to LoveHate).
As part of character generation, I'm wanting to access the "Quest Journal" component as each character is created and set a unique value for "ID" and "Display Name".
I'm struggling to set the "ID" field in the quest journal (although I suspect that I'm overlooking something obvious ).
Here is the current code from the script in question as it stands:
Code: Select all
using UnityEngine;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using PixelCrushers.QuestMachine;
... //tl;dr unrelated code
GameObject newHero = Instantiate(heroPrefab);
heroList.Add(AddGroundObjectAtPosition(cityPosition, newHero));
string newID = ("hero " + heroList.Count);
QuestJournal tempJournal = newHero.GetComponent<QuestJournal>();
tempJournal.id.stringAsset.text = newID; //NullReferenceException fires on this line
...
Any advice would be appreciated.
Biscuit