Search Unity

Own Random Sequence

Discussion in 'Getting Started' started by darthachill, Apr 7, 2015.

  1. darthachill

    darthachill

    Joined:
    Jan 25, 2015
    Posts:
    27
    Is there any function in C#/Unity, that allows me set my own random sequence ?
    for example in one State, I want to choose one number between (1 ,3, -2), and in another case (1,20,3,4,5)
    I can do something like that:

    int[] tab = new int[3] {1,29,4};
    int chosen = tab[ Random.Range(0, tab.length) ];


    Of course I can write my own function, but if Unity has that one, it won't be necessary.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Nothing built in. I'd suggest extending Random if you use it a lot.