- Home /
public variables in script communication
I'm trying to make difficulty buttons that have two variables the need changing for each difficulty, the number of enemies that spawn in the first wave and the speed they gain with each new wave. So I have a difficulty button script for all three buttons but I'm not sure how to input each unique public variable from each difficulty button script and add that in the spawn manager script.
I tried putting the update function that I use to call the waves from the spawn manager script to the actual difficulty button script, but because title screen containing the buttons is deactivated after use the script is never run.
So how can I get the unique public variables from each difficulty button script and input them where "startEmemiesNum" and "speedToAdd" are now?
void Update()
{
enemyCount = GameObject.FindGameObjectsWithTag("Enemy").Length;
if (enemyCount == 0 && gameIsActive)
{
SpawnEnemyWave(startEnemiesNum, speedToAdd);
UpdateWave();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613015024im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Inherit functions that work properly 1 Answer
Scene tree text generation 1 Answer
Gas Fuel Implementation 0 Answers
BOLT FlowStateMachine for entire scene? 1 Answer
Is my controller script good? 2 Answers