
Why might I use this?
Imagine (for example) you are designing some UI for your game, and you have a lives counter, with a particle system for effect. You want the number of remaining lives to dictate the particles emission rate, so you add some code like:
myParticleSystem.emissionRate = lives;

Now, the more lives you have, the more particles there is. But now you decide that a Y=X relationship isnt right, so you multiply the number of lives and you get
myParticleSystem.emissionRate = lives * 5;

and this is better, but really you want a greater increase in particles the higher your lives go, so you might try using the Pow() function
myParticleSystem.emissionRate = Mathf.Pow( lives, 2 );

and this is better again, but maybe a different value of Pow, or different multiple of lives would give you the curve that you want. It’s difficult to visualize it, you want a way to adjust the values and quickly see the relationship between the input (lives) and output (particle rate).
This applies to any other potentially non-linear relationship as well, for example:
-
enemy level (0 > 100) - item drop rate (0.05 > 0.1)
-
remaining lives (0 > many) - extra-life powerups (some > few)
-
vehicle speed (0 > fast) - dirt particles (0 > max) or engine volume (off > loud)
So I made this Node-based maths calculator:
You can create a node system, define variables, and adjust the values to see the resulting behavior.
The idea is, create a system that works right for your purpose, then click the button to “Generate Code” which you can paste into your script (not yet implemented edit: done).
I’d also like to put in a function where you can plot known values, an it adjusts the variables to closely match the plot.
It’s also got save/load function, and a few extra controls:
Drag empty area to pan the view
Right-mouse an empty area to add a new node
Right-mouse a node or group selection to delete it
Middlemouse to select groups
Alt to clone the currently selected group
Its got a bunch of node types, so should be able to recreate anything that Mathf. is capable of
20
Here’s the package (1 script and one icon). I’d appreciate some feedback on function and features
1885089–128244–Grapher.unitypackage (41.1 KB)





