Just to be not much complicated… I just want to print one random value between 0 to 3 on trigger enter… But I am getting somethings 1 or 2 outputs printed! I want just a single output to be printed, As I can use them in if statement
Here is my code…
C#
void OnTriggerEnter()
{
int randomNum = Random.Range(0, 4) ;
//As I want to get one of the 3 outputs
print(randomNum);
if (randomNum == 1)
{
// Do something....
}
if (randomNum == 2)
{
// Do something....
}
if (randomNum == 3)
{
// Do something....
}
}
I am getting out put in Unity Concole as:
2 and 3 Or sometimes 1 and 3 or just 1
Don’t worry about that print I had done [string Num = randomNum.ToString();] and printed a value of [Num] as [print(Num);] The only problem is I am getting Multiple Outputs, I think you get what I mean Plz help to over come this… Thank you!