I have a script that generates map for my runner game, using random tiles
void Update()
{
if ((instantiatedPrefab == null) ||
(instantiatedPrefab.transform.position.y <= spawnPositionY - tileScale))
{
for (float i = 0 - (tileScale * (mapWidth / 2)); i <= mapWidth / 2; i += tileScale)
{
instantiatedPrefab = Instantiate(tilePrefabs[
UnityEngine.Random.Range(0, tilePrefabs.Length)
], new Vector2(i, spawnPositionY), Quaternion.identity, mapHolder);
}
}
}
Each tile falls down using this script:
void Update()
{
transform.position -= new Vector3(0, fallSpeedController.fallSpeed * Time.deltaTime, 0);
}
The fallSpeed
is constantly increasing.
As fallSpeed
grows, the gaps between rows become bigger.
What can I do to fix these gaps?