Hi there, i’ve been trying to figure out this for all day, but it seems more complicated than i can handle right now.
With these three variables (DistanceThreshold, CurrentDistance, VarX) i need to decrease “VarX” by exponentially smaller amounts depending on how small the value of “CurrentDistance” is in relation to the DistanceThreshold.
Let’s say these are the values (This is pseudo-code):
DistanceThreshold = 600;
VarX = 40; // 40 is the max value of this variable, the minimum should be 0
CurrentDistance = GetDistance();
Every frame i check if CurrentDistance is smaller than DistanceThreshold. If that is the case, based on how close i am to the target (AKA how low CurrentDistance is), i decrease “VarX” by some amount. But i want to do it exponentially, meaning that the lower “CurrentDistance” is, the smaller the number i subtract from VarX will be.
In a graph, it would be something like this (It’s probably mathematically impossible but you get the idea. I don’t need a precise value for VarX, i just need it to be low, like ~1.2 or below)