I want to find a point (as a vector) between two vectors based on a float value between 0 and 1? How do I find that point?
The value between 0 and 1 will be derived from a timeline.
I tried this but it did not work:
I want to find a point (as a vector) between two vectors based on a float value between 0 and 1? How do I find that point?
The value between 0 and 1 will be derived from a timeline.
I tried this but it did not work:
I think you want to Lerp (linear interpolate) between two vectors:
https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Vector/Lerp_vector/index.html
The Alpha is the value between 0 and 1.
I would opt to create a direction vector from the two vectors.
Then using the distance between the two vectors you can simply take a percentage of to move the start point in the direction of your target vector by the amount you desire.
Lerping worked perfectly after some trial and error.
C++ Version
FVector Direction = (EndPositionActor->GetActorLocation() - StartPositionActor->GetActorLocation()).GetSafeNormal(); | ||
---|---|---|
float DistanceBetweenToFVectors = EndPositionActor->GetDistanceTo(StartPositionActor); | ||
FVector AnswerPosition = StartPositionActor->GetActorLocation() + ( Direction * (DistanceBetweenToFVectors * 0.5f)); |