Basic calculations! - Mathematics Script
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!
HOW TO USE
- Assign the script in a Game Object.
- Assure the Game Object is present in the scene you are going to use it
- From any script yo can write down:
Mathemathics.calculate.Function();
AVERAGE
Mathematics.calculate.Average(new float[] {8, 7, 5, 10});
This function gets the average from an array of float numbers.
PERCENTAGE
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
PROBABILITY
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.
RANGE
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);
Files
AsdoBlog
Some assets and personal blogs!
More posts
- NUEVO JUEGO - Night of the Living PinatasSep 11, 2023
- Como hacer un logo épico - AsdoBlogNov 04, 2022
- Sistema de Idiomas - AsdoBlogJun 19, 2022
- Paleta limitada - AsdoBlogMay 21, 2022
Leave a comment
Log in with itch.io to leave a comment.