Random Class (stochastic number)

Source: Internet
Author: User

Preface: Always forget how to use. On the Internet a check, are some have not ...

The simplest but most commonly used method: the Random.next method

First, instantiate an object for the random class:

1 Random n=new random ();

The next method is available in two ways, one with one parameter and one with two parameters.

First, generate a random number with a maximum value of 8 (including 8)

1 int m; 2 m=n.next (8);

Ii. random number of generation [0,7] Interval

1 int A; 2 A=n.next (0,7);

It's good to use the Random.range method directly inside unity.

Returns a floating-point number between 10 and 10, containing-10 and 10

1 random.range (-ten);

More of us to go through the game Bull manual

Random Class (stochastic number)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.