Now that we have a foundation, let's make it so that we can continue running instead of stopping after a short time by spawning copies of this basic tile in front of each other:
- To start off with, we have our prefab, so we can delete the original Basic Tile in the Hierarchy window by selecting it and then pressing the Delete key.
- We need to have a place to create all of these tiles and potentially manage information for the game, such as the player's score. In Unity, this is typically referred to as a GameController. From the Project window, go to the Scripts folder and create a new C# script called GameController.
- Open the script in your IDE and use the following code:
using UnityEngine;
/// <summary>
/// Controls the main gameplay
/// </summary>
public class GameController : MonoBehaviour
{
[Tooltip("A reference to the tile we want to spawn")]
public Transform tile;
[Tooltip("Where the first tile should be placed at"...