So I’m making kind of an endless runner esk game, and my plan is to have track pieces that spawn as you go. So far that’s all working great, I have an endless track and thats perfect. Now I’m trying to figure out how to make it spawn a variety of track pieces, such as a straight one sometimes, other times a curve, etc… My current code is
void Update () {
transform.position = new Vector2 (transform.position.x - player.speed, transform.position.y);
if (transform.position.x <= -100)
{
Destroy (gameObject);
}
if(transform.position.x <= 18 && spawned == false){
var track = (GameObject)Instantiate (
trackPrefab,
trackSpawn.position,
trackSpawn.rotation);
spawned = true;
}
}
I’m unsure as to how to make it spawn one of a few different options, any suggjestions?
Also I’m aware that similar questions have been answered, but none of the answers have completly made sence to me, so I’m hoping to get a more direct answer to my specific problem.