Calculate point over the default point

Hi!

How can I calculate that point, what is 2x-3x over the default point?
I mean, I have the default point, the player position, and the direction between them. I want to move the player to the direction of the default point, but I also want to move it over it, still in that direction.
How can I achive that?

If I understand the question correctly, you have two Vector3’s, position A and B. You want to find position C, which is along the line from A to B, but 2-3 times further. Is that correct?
If so, then you want this:

float multiplier = 2f;
Vector3 result = (positionB - positionA) * multiplier + positionA;

(By the way, this is the same exact math that happen in functions like Vector3.Lerp. The Lerp functions do clamp the multiplier between 0 and 1, though, so they aren’t applicable to this particular use case.)

2 Likes

That’s it! Thank you very much for your help!

I just want to point out that StarManta (as usual) is completely correct in his analysis, but that Unity also offers Unclamped versions of most if not all of its Lerp functions. For example:
https://docs.unity3d.com/ScriptReference/Vector3.LerpUnclamped.html

2 Likes