Can anyone help me with a graph: exponential but never reaches 1
Consider a graph of the form $\displaystyle f(x)=1-e^{-kx}$.
Let $k$ be positive.
Let's say there's a point at which the growth slows down past a certain point, $a$.
The larger $k$ is, the smaller $a$ is.
So I'm curious, because this will help me answer your question more accurately and thoroughly, what is this graph representing?
Is it saying that the character accelerates as they run, but doesn't go faster than $1$ m/s? Because that's what I understand.
Or maybe, is it saying that as you level up your character, they run faster and faster? But even at higher levels, they will not run $1$ m/s, although they get closer?
A few possibilities, depending on what you have available:
- $ 1-e^{-kx} $ for ($k>0$) will be the first one any mathematician will recommend.
- If you don't have $\exp$, $1-2^{-kx}$ (again, $k>0$) is probably easier to implement depending on what units you're working with.
- $\frac{2}{\pi}\arctan{x}$.
- On the more complicated side, $\tanh{x}$.
The latter two have the advantage of having similar behaviour for negative values since they are odd functions.
You can try a Hill function. The function $$ f: x \mapsto \frac{x}{x+h} $$ has the following properties:
- $f(0)=0$;
- $f$ is increasing;
- $\lim_{x \to \infty} f(x) = 1$, so $f$ approaches $1$ as $x$ grows large;
- $f(h) = \frac12$, so by choosing the $h$ parameter one can control at which value of $x$ the function takes half its maximal value.
Example for $h=1$ (blue), $h=2$ (orange) and $h=10$ (green):
To get functions with a different shape, you can experiment with functions of the form $x \mapsto \frac{x^n}{x^n+h^n}$, where $n$ is a second parameter. These functions also have the four properties listed above.
One such solution is
$$ f(x) = 1 - e^{-2x} $$
Advantage to @Saketh Malyala for providing the answer first.
A family of curves: $$ f(x) = 1 - e^{-kx} $$