C
C
Cetar2021-07-31 00:50:41
Android
Cetar, 2021-07-31 00:50:41

How to randomize levels for vertical runner?

There is a code but it doesn't work for some reason???
There are walls they move to the bottom, and I need so that the prepared levels that I have in prefabs are compared when other walls go down, then the walls go down and spawn new ones but ready with different obstacles
1 Script Responsible for Wall Movement:
{
public float speed ;

private void Update()
{
Tranform.Translate(Vector2. down * speed * Time. deltatime);
speed += spawner. speed Increase * Time.deltaTime
if (transform.position.y < 0 && !spawned
}
2 Wall Spawn Script
public GameObject[] wall;
public float speed;
public speedIncrease

private void Update()
{
speed += speedIncrease *Time.deltaTime;
}
public void SpawnWave()
{
int rand = Random.Range(0, wall.Lenght);
Instantiate(wall[rand], transform.position, Quaternion.identity);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crebor, 2021-07-31
@Crebor

private void Update()
{
speed += speedIncrease *Time.deltaTime;
}
public void SpawnWave()
{
int rand = Random.Range(0, wall.Lenght);
Vector3 random_value = new Vector3(Random.Range(0, 0,1f),0,0);
Instantiate(wall[rand], transform.position+random_value, Quaternion.identity);
}

Or Instantiate(wall[rand], random_value, Quaternion.identity);
It's like one of the options. new Vector3(Random.Range(0, 0,1f),0,0) - perhaps the parenthesis is missing here, please correct

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question