title: Instantiate a prefab?
body: <p>I am making a crossy road game with 4 prefab "chunks" that I want to create when the player touches the collider named . My code randomizes which chunk is loaded when the player hits it and then spawns the next chunk. For some reason though, it doesn't recognize my prefab and I want to load the chunk 25 z-value ahead of the last one. Code:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  
  
  public class ChunkLoader : MonoBehaviour {
  int level = 0;
  public Transform chickenpos;
  // Use this for initialization
  void Start () {
  
  }
  
  // Update is called once per frame
  void Update () {
  
  }
  void spawnChunk()
  {
      float chunkload = Random.Range(0, 2);
      Debug.Log(chunkload);
      if (level &lt;= 10)
      {
          if(chunkload &lt;= 1 )
          {
  
           Instantiate  (ChunkA1, chickenpos);
  
          }
      } 
  
  }
  void OnTriggerEnter(Collider other)
  {
      if (other.tag == "Loader")
      {
          level = level++;
          Debug.Log(level);
          spawnChunk();
      }
  }
  }
  </code></pre>