DropDown in scene 1 to change value in scene 2? Please help!
Hi guys! Hope you are all doing well :) I have been stuck on this for 2 days and am still completely stuck, please help me out if you know how to make this work! I am making a game very similar to Frogger a frog crossing a road the player has to dodge the cars to get to the other side of the road.
Here is what I am trying to do:
I have a game with scene 1 and scene 2; in scene 1 I have a DropDown called "ChooseDif" with 3 difficulty options. In scene 2 I have a CarSpawner object with a spawnDelay variable which controls the speed of the cars.
I need the option "easy" (from DropDown in scene 1) to set spawnDelay (in scene 2) to "0.5", and so for "medium" to "0.3" and "hard" to "0.1"…
I haven’t managed to write any script for the dropdown, however this is the CarSpawner script which creates the variable spawnDelay (and it works):
public class CarSpawner : MonoBehaviour {
public float spawnDelay = .3f;
public GameObject car;
public Transform[] spawnPoints;
float nextTimeToSpawn = 0f;
void Update ()
{
if (nextTimeToSpawn <= Time.time)
{
SpawnCar();
nextTimeToSpawn = Time.time + spawnDelay;
}
}
void SpawnCar ()
{
int randomIndex = Random.Range(0, spawnPoints.Length);
Transform spawnPoint = spawnPoints[randomIndex];
Instantiate(car, spawnPoint.position, spawnPoint.rotation);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612164029im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
My project's UI keeps resizing itself and I have no idea why. 0 Answers
Player Party Save 0 Answers
Saving In Between Scenes and Program Exit 0 Answers
Save graphics and volume settings 0 Answers
Disable a single Dropdown option. 2 Answers