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?

1 Like

I believe youâ€™d just do `B * A`

.

Not too experienced with Vector math so I could be wrong.

1 Like

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.

7 Likes

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

4 Likes