Slavq
(Slavq)
August 18, 2016, 7:46pm
1
Let me explain this with the picture:
How to get distance between these vectors, but only along specified axis? So it would return a distance just like if they were ON this axis.
I’m working on 3D Vectors, but this is a 2D example, just for simplicity.
Attempting to answer this live: Twitch
Edit: Whoops! Thought this was in the C++ section.
Assuming you have:
FVector Arrow;
FVector RedDotPosition;
FVector GreenDotPosition;
//The key is to normalize the arrow vector, so it doesn't scale your distances.
Arrow.Normalize();
float RedDistanceAlongArrow = FVector::DotProduct(Arrow, RedDotPosition);
float GreenDistanceAlongArrow = FVector::DotProduct(Arrow, GreenDotPosition);
float Distance = GreenDistanceAlongArrow - RedDistanceAlongArrow;
If you want displacement, then multiply it by your normalized Arrow FVector.
Slavq
(Slavq)
August 19, 2016, 10:03am
4
This works great, thank you very much!
Slavq
(Slavq)
August 19, 2016, 10:04am
5
+1 For the attempt ;D Here is what I meant:
this helped me so much. I’m building a vaulting system and was able to use these dot products to calculate where along a wall the player can mantle. THANK YOU