title: Unity3D spawning 2d objects at fixed locations
body: <p>I have an object that when clicked it is destroyed and spawns randomly somewhere else on a timer. I'm trying to make it so instead of random spots it shows up at fixed locations.</p>
  
  <p>I also want them to randomly spawn at those fixed locations on a timed interval, one at a time.(so if it appears in one location for lets say 5 seconds, it will be destroyed and the next one will appear in a different location.)</p>
  
  <p>I attempted to do fixed spawn locations, but the void spawner doesn't want to work.</p>
  
  <p>I get a "The object of type "GameObject" has been destroyed but you are still trying to access it".</p>
  
  <p>I can fix this by commenting out the On_TouchStart destroy line, but I need it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Spawner : MonoBehaviour {
  
      public float AppearTime = 0f;
      public Transform[] teleport;
      public GameObject[] prefab;
  
      void Spawner(){ 
          int tele_num = Random.Range(0,5);
          int prefab_num = Random.Range(0,3);
          if (prefab !=null){
          Instantiate(prefab[prefab_num], teleport[tele_num].position, teleport[tele_num].rotation );
          }
      }
  
  
      void StartTime()
      {
          StartCoroutine(DoTime());
  
      }
  
      void OnEnable(){
          EasyTouch.On_TouchStart += On_TouchStart;
      }
  
      IEnumerator DoTime()
      {
          yield return new WaitForSeconds(AppearTime);
          Spawner();
  
      }
  
      void On_TouchStart (Gesture gesture){
  
          if (gesture.pickObject != null){
              Destroy(gesture.pickObject);
              StartTime();
          }
      }
  </code></pre>
  
  <p>If anyone could lead me on the right track I'd appreciate it.</p>
  
  <p>Thanks.</p>