Posted August 09, 2021 by Asdonaur
Hi!
I'm Asdonaur, and here is my first script asset!
This script lets you use various functions to get random numbers and use some basic calculations!
For now, it only has 4 functions, but you're free to suggest more functions!
Now, I'm explaining how to use it!
Mathemathics.calculate.Function();
Mathematics.calculate.Average(new float[] {8, 7, 5, 10});
This function gets the average from an array of float numbers.
Mathematics.calculate.Percentage(ENTIRE, NUMBER));
This function gets how many percentage is NUMBER from ENTIRE.
Returns in entire numbers.
float percentage = Mathematics.calculate.Percentage(200, 50)) = 25; percentage / 100 = 0.25f
Mathemathics.calculate.Probability(PROB, BETWEEN);
This function choses randomly an entire number between 1 and the variable BETWEEN.
Then it returns true if the number got was less or equal to PROB.
For example, if we write Mathemathics.calculate.Probability(3, 10), it meas we are asking for a random boolean value with 3 probabilities from 10.
Mathematics.calculate.Range(ONE, TWO);
Returns a random float value between ONE and TWO.
It works exactly like Random.Range(), but with a small difference.
If you leave TWO as 0 or no value, it will be replaced with negative ONE.
Mathematics.calculate.Range(1.3f) = Mathematics.calculate.Range(1.3f, 0) = Mathematics.calculate.Range(1.3f, -1.3f);