Search Unity

Weird random behaviour.

Discussion in 'Project Tiny' started by Seaqqull, Nov 17, 2020.

  1. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    23
    Hello. In the update method of my system I try to generate some random numbers(1*). Tick values (2*).
    - But somehow in [DebugText3] (using Unity.Mathematics.Random) I always get numbers less than 0.1
    - In [DebugText4] (using UnityEngine.Random) I get numbers from range (-100, 100).
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      13 KB
      Views:
      34
    • 2.PNG
      2.PNG
      File size:
      1.8 KB
      Views:
      35
  2. djsell

    djsell

    Joined:
    Aug 29, 2013
    Posts:
    59
    As far as your seeding goes, it will always be in the range 0-999 because you're only getting the millisecond component, which is less than ideal (seeding 0 even causes an exception iirc). I'd recommend using Ticks instead.
     
    Seaqqull likes this.
  3. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    23
    Using Ticks instead of Milliseconds helped with [Unity.Mathematics.Random]. Thank you ^_^
     
    djsell likes this.
unityunity