Finding a point beyond two vectors

After searching for a solution to my problem, I’m finally relenting and asking my first question here. It’s not really a Unity specific question, more of a mathematical question, but I’m hoping someone can help.

What I’m trying to do is write a script that moves an object to one point from another point, but give it a little elasticity at the end of its journey. Sort of like a little wobble back and forth after it reaches the destination.

Vector3.Lerp works fine for getting the object from one point to another, but that doesn’t give me the elasticity at the end that I want. If there’s an easy way to accomplish this, I’m all ears, but my current implementation idea is to locate a point beyond the destination in the same direction of travel, and use lerp and an ever decreasing variable to add the back and forth travel that I’m looking for. Thus Vector3.Lerp(origin, destination, 1.0) would put me at the overshoot, whereas Vector3.Lerp(origin, destination, 0.95f) would put me at my true destination). I hope that makes sense.

Anyway, all of this to get to my question. I’m not familiar with Vector math, and it’s been well over a decade since I’ve done any math beyond algebra (I usually do business software), so I’m not aware of how to find a point beyond my destination. What is the process of taking an origin vector and a destination vector and finding a point that is X units past the destination on the same line?

Thanks in advance for any help you can offer me.

How about Vector3.Slerp? or Vector3.SmoothDamp?

Here’s some math stuffs, sounds like you want the Berp function. (Oh yeah. :wink: )

–Eric

LightStriker: I hadn’t checked SmoothDamp. Looking at the documentation, it says “The vector is smoothed by some spring-damper like function, which will never overshoot.” It won’t work for my application.

Eric: That’s perfect! I had to play with some of the values in the Berp function to make it to my liking, but it works great!

Also, btw, I found the equation used by Lerp (percent * (destination - origin) + origin). While the Vector3.Lerp function errors if you try to send it a percent greater than 1, that calculation seems to work fine with it. So that answers my question, but the Mathfx.Berp function gives me the rebound I’m looking for.

Thanks a lot for the help!