Search Unity

  1. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  2. Curious about what's going to be in 2021.1? Have a look at the 2021.1 beta blog post.
    Dismiss Notice
  3. Want to see 2021.1b in action? Sign up for our 2021.1 Beta Webinar on February 25 for a live presentation and a Q&A session with guests from R&D.
    Dismiss Notice

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:
      23
    • 2.PNG
      2.PNG
      File size:
      1.8 KB
      Views:
      24
  2. djsell

    djsell

    Joined:
    Aug 29, 2013
    Posts:
    37
    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