Am i the only one?

am i the only one who dosen’t understand vector maths at all ?
i mean how when i multiplying things i came out with a result

Could you be more specific about which one in particular?

how would i know if i just do that auto ScreenLocation = FVector2D(ViewportSizeX * CrosshairXLocation, ViewportSizeY * CrosshairYLocation); i came out with a result which is the pixels thing … , and if i do that auto EndLocation = StartLocation + (LookDirection * LineTraceRange); i came out with another result which is the end location

That’s just multiplying percentages. If the viewport size is 800 x 600 and the X and Y location of the crosshair is at 0.5 (half way) then that’s just going to give you an FVector2D with an X and Y of 400 x 300.

That does two things.

  1. LookDirection is a unit vector, it is a vector that has the length of 1 i.e. it is just a direction, no magnitude. To keep it simple all examples are in 2D.

    Say the LookDirection is looking directly right so you have a vector of (1,0) and have the range be a value of 5. Multiplying a vector by a scalar (single number) scales it, it does so by multiplying each component of the vector by the scalar. So that will be (1 * 5,0 * 5) = (5,0) . So that’s the first part LookDirection * LineTraceRange

  2. Adding vectors puts the tail of one on the tail of the other. Say we have a vector of (2,3) that is the player’s location and the (5,0) vector calculated previously.

    (Red = (2,3), Blue = (5,0))

    And if we put the head to the tail of the other

    We get the value (7,3) which as you can see is exactly five units to the right of the players location. The addition is just a component-wise addition (2 + 5, 0 + 3) = (7,3)

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

Privacy & Terms