I am a bit fuzzy on vector math. How would I do the following:
A = Vector3 (with a certain magnitude)
B = Vector3 (unit vector with the direction I want to point in)
How do I get a Vector3 with the magnitude of A but in the direction of B?
I am a bit fuzzy on vector math. How would I do the following:
A = Vector3 (with a certain magnitude)
B = Vector3 (unit vector with the direction I want to point in)
How do I get a Vector3 with the magnitude of A but in the direction of B?
I believe you’d just do B * A
.
Not too experienced with Vector math so I could be wrong.
Assuming these are vectors, not points…
-- Assuming B is a unit vector...
C = B*A.Magnitude
-- If B is any vector...
C = B.Unit*A.Magnitude
In other words, you take the vector with a length of 1 and multiply it by the length you want it to be.
Just to break it down a bit more, we can look at it like this:
We want the resulting Vector3 to be the length of Vector A. We can get this number using “A.Magnitude”
We get the direction of Vector B by doing “B.Unit”. This gives us a unit vector, meaning it has a length of 1.
Thus, we can get Vector C as follows:
C = A.Magnitude * B.Unit
Edit: Corecii beat me to it