Search Unity

Why is Random.Range returning same number always?

Discussion in 'Scripting' started by Shadowing, Jun 17, 2019.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Can someone please help me understand this.
    Why does this returns 13 every time.
    I added the IniState() that used to fix this problem but it doesn't anymore.
    Unity 2019.1.6

    Code (csharp):
    1.  
    2.  
    3.             UnityEngine.Random.InitState(DateTime.Now.Millisecond);
    4.             int Deathanimation = UnityEngine.Random.Range(1,13);
    5.  
    6.  
     
  2. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    nevermind I figured out why. This was returning right. had a variable called MaxDeathAnimation and I was reading that by mistake.