if (timeLeft <= 0)
{
if (chanceToSpawnTarget == 100)
SpawnTarget();
else if (random >= 1 - chanceToSpawnTarget / 100)
SpawnTarget();
else SpawnNeutral();
Debug.Log(random);
timeLeft = timeBetweenSpawn;
}
I posted the code above.
What this should do is make a random value (not shown in this part) and if the value is bigger than the chance to spawn target it should spawn the target. Chance to spawn the neutral is a public variable and can be changed in the editor while the target chance depends on it.
chanceToSpawnTarget = 100 - chanceToSpawnNeutral;
But it doesn’t matter what value random is it will always spawn neutral or whatever is the last
requirement. What am I doing wrong and what can I do to fix it?