For my quest system, I store empty’s with a script for that quest (questBlock) and instantiate them when beginning the quest. This code actually runs fine, but I want to organize the questBlocks into an arraylist (ql) for easier sorting (the code that has been commented out).
Problem is, I get a conversion error on “Quest = ql” and another on “Instantiate(ql[10]”
if questBlock is a GameObject when added to an arraylist, why is it not a GameObject when accessed?
using UnityEngine;
using System.Collections;
using System;
public class QuestSystem : MonoBehaviour
{
public GameObject questBlock;
public ArrayList ql = new ArrayList();
void Start ()
{
ql.Add(questBlock);
//GameObject quest = ql[0];
//GameObject current = (GameObject) Instantiate(ql[0], transform.position, transform.rotation);
GameObject current = (GameObject)Instantiate(questBlock, transform.position, transform.rotation);
}
}