How to define and use Random in Unity using C#
Random number are quite often used Unity games, it help to create random position of enemies, attack range and so on. There are two main override methods in the Unity:
// public static float Range(float min, float max); Random.Range(-10.0f, 10.0f); // public static int Range(int min, int max); Random.Range(0, 10);
The 1st output will be a float from between -10.0 and 10.0, note that -10.0 and 10.0 are inclusive.
The 2nd output will be an integer between 0 and 10. note that 0 is inclusive but 10 is exclusive.
Join the newsletter to receive the latest updates in your inbox.