Answer the question
In order to leave comments, you need to log in
How to make a random event generator in unity3d?
There is an event (Attack of enemies, rain, cold, attack of wild animals, etc.), how to trigger one of the random events on a random day
void Timer () {
time+=Time.deltaTime;
if (time > 480) {
day += 1;
time = 0;
}
}
Answer the question
In order to leave comments, you need to log in
If all events are of the same type, and, for example, are stored in the same array, then something like this can be done:
If they are of different types, then you can do this:
switch (Random.Range(0, N))
{
case 0:
EventEnemiesAttack();
break;
case 1:
EventWeatherRain();
break;
case 2:
EventWildAnimalsAttack();
break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question