I feel like I'm not understanding vector math

It’s just not clicking for me. I did the challenge in the video and couldn’t figure out why the debug line would not face in the same direction as the camera. I assumed the GetForwardVector() function would return the forward vector of the component.

What I was doing:

image

While the issue was that I was not adding it to the starting vector, which Sam covers at the end of the lecture.

This isn’t really a question more so than just a complaint I guess? There is a lot of math that I simply don’t seem to be able to wrap my head around and it can be very frustrating at times.

It does do that.

The forward vector is a unit vector; which is a vector with the length of 1.
If you were to do Pythagoras on the axes of it you would get 1.

This allows you to scale it by a scalar quantity (just a number) like you have done in code. You now have a vector going in the same direction as the component’s forward vector with the length of MaxGrabDistance, this is in arbitrary space. Adding vectors together can be thought of putting the tip of one to the tip of the other. So if you take this vector that’s in arbitrary space that’s MaxGrabDistance in the direction of the component and add it to the start vector, you will end up with a vector that is MaxGrabDistance away in the same direction.

Here’s a 2D example:

Say the player is at (5, 6) and the component is looking directly right. this would be represented with the unit vector of (1, 0),
If you wanted to reach out 5 units in that direction you would have

( 5 * 1, 5 * 0) = (5, 0)  // Forward * Distance
(5, 6) + (5, 0) = (10, 6)

Plotted out:

The blue arrow was made by simply duplicating the arrow and placing it at Player.

3 Likes

Thank you for such a detailed response. It does help to visualize, I have also gone back to the vector math video in the course.
I think I need to experiment more with vectors, perhaps using debug lines for visuals and just try to get certain results.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms