I'm designing a game where characters' speed starts slowing down after different distances. I'm not advanced in mathematics so I'm not sure if I'm on the right track. After researching on wikipedia I found information on Gompertz function and Sigmoid function. My primary question is if one of these are the formula I need or is there a simpler way to describe what a characters speed will be?

Here is a graph of the dynamic.

To be specific: The max speed a character can have is $32$m/s, the minimum is $16$m/s. The most unfit character starts to slow down immediately from $32$m/s to $16$m/s in $16$ seconds. The most fit character doesn't start slowing down until after $16$ seconds. The variable of when the slow-down begins can fall anywhere between $0$s and $16$s of travel. Would be awesome if someone could show what the formula would look like for this.


Here's a "modular" explanation, in the hopes that you can easily modify (if necessary) it to suit your needs.

Let $S$ (for speed) be a function satisfying $0 \leq S(t) \leq 1$ for all real $t$; $S(t) = 0$ for $t \leq 0$; $S(t) = 1$ for $1 \leq t$.

The "cubic interpolation" is probably smooth enough to suit your needs: $$ S(t) = 10t^{3} - 15t^{4} + 6t^{5} = t^{3}\bigl(10 + t(-15 + 6t)\bigr),\quad 0 \leq t \leq 1. $$ (The rightmost expression is called Horner's form, and minimizes the number of multiplications needed for algebraic evaluation.)

If a character starts at speed $s_{1}$ at time $t_{1}$ and ends at speed $s_{2}$ at time $t_{2}$, their speed at time $t$ can be modeled by $$ s_{1} + (s_{2} - s_{1})S\left(\frac{t - t_{1}}{t_{2} - t_{1}}\right). $$

  • $\begingroup$ Thanks for the reply, Andrew. I don't know how I did it but I managed to make a graph that looks like I want it. Is this the simplest solution or have I complicated things? $$ f\left(x\right)=\frac{.96}{.06+1000\cdot e^{-.42x}}+16 $$ $\endgroup$ – Antonio Jun 26 '16 at 11:45
  • $\begingroup$ "Simplest" is partly in the eye of the beholder, so if it works for you, it suffices. In case it matters, mathematically that function doesn't ever achieve either value $16$ or $32$ (the first term is strictly positive and strictly less than $16$), but it does come So Close That No One Will Notice. :) $\endgroup$ – Andrew D. Hwang Jun 26 '16 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.