We added code for generating game area at runtime.
so basically there is a 2d collider attached at the end of each tile. when our man camera hits that collider a tile is instantiated at the very collider it collided with.
here is the code for tile generator.
public class TileSpawner : MonoBehaviour
public GameObject TileType1Prefab;
public GameObject TileType2Prefab;
public GameObject TileType3Prefab;
private BoxCollider2D _collider;
private BoxCollider2D _camBounds;
private GameObject _tileType1PrefabRef;
public void Start()
_collider = (BoxCollider2D)GetComponent<BoxCollider2D>();
public void OnTriggerEnter2D ( Collider2D other)
if (other.GetComponent<CameraBound>() == null)
_collider.enabled = false;
public void SpawnNextTile()
_tileType1PrefabRef = (GameObject)Instantiate(TileType1Prefab, transform.position, transform.rotation);
Thanks for reading.
if you want to check out some of our projects please subscribe to our YouTube channel:
You can check up our work in progress games here:
If you are looking for solutions to game development issues see our blogs here:
If you like our projects please sign up for our newsletter at the bottom of this Page.