I'm trying to program a circle to move towards a moving target. As the circle gets closer to the target, it increases in speed. I'd like to increase it exponentially, but I'm having trouble plugging the math into a function. I have the circle's x and y, the target's x, y, and speed. I can make the circle slow down as it moves closer by taking the cirlce's location minus the target's location and dividing it by a constant, then subtract that from the circle's location, moving it. I've looked at many equations for exponential easing, but all require time. I don't see how I can add time into my function.
I've looked at many equations for exponential easing, but all require time. I don't see how I can add time into my function.
Implicitly, you're already dealing with time between function calls. You just aren't dealing with it very well. Dealing with it explicitly will make accomplishing things like you've indicated you want to easier and it will also make your code more robust.
A simple example with an object moving around a circle is to have the the angle theta as a function of time. Then have separate functions for the X and Y ordinates in terms of theta. Now all of your functions depend on time.
One could make your functions dependent on more than one variable as in time and the distance from the target, so you can do varying acceleration or whatnot.