- Home /
Multiple NPC with same script but different value
Hi, i'm trying to make an android 2D RPG games where each NPC has a quest to give to the player... They all have the same scripts but different Quest ID, I would like to assign a button where it could check all the quest on different NPC... I have tried to assign a button but it only check on one NPC and won't check the quest available for the other NPC... I wonder if I could do another script or what? Here's the script I use on the NPC public class QuestObject : MonoBehaviour {
public bool inTrigger = false;
public List<int> availableQuestIDs = new List<int> ();
public List<int> receivableQuestIDs = new List<int>();
public GameObject questMarker;
public Image theImage;
public Sprite questAvailableSprite;
public Sprite questReceivableSprite;
void Update ()
{
if(inTrigger && Input.GetKeyDown(KeyCode.V))
{
QuestUIManager.uiManager.CheckQuests(this);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
inTrigger = true;
}
}
void OnTriggerExit2D(Collider2D other)
{
if(other.tag == "Player")
{
inTrigger = false;
}
}
}
Also since my NPC is destroyable after changing scene it means this script that I will assign to a button will gone after changing scene making the button can't function anymore... I would love a help on the code to make the button able to read all the quest from QuestObject I gave to all of my NPCs
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
UI Buttons sometimes not detecting touch 1 Answer
Adjusting UI to cellphone screen size 0 Answers
Character Controller with Unity User Iterface input 1 Answer