So I have a snall script which has a void Start(), in which a random number gets generated. Now I have a function to spawn enemies and I wan’t it to use the random number to know which enemie to spawn.
But when I try to use the random number the function always has the same number, and its the one I gave it at my MonoBehavior.
Here is a simplified version of my script:
`
int g;
void Start() {
int g = Random.Range(0, 5);
SpawnEnemie()
}
void SpawnEnemie() {
if (g == 1) {
dostuff
}
if (g == 2) {
dostuff
}
}`
Now everytime I run it g stays 0 and it isn’t a random number.
Also the enemie is only supposed to get spawned once on start, thats why SpawnEnemie is only called in Start.