Hi, I’m trying to understand exactly how the trace by box works. I can make it work when I just input the values.
I assume it works by taking the center of the box, start and end and then adding the size (half size values) to build the box. Because I’m trying to make it work as a drag box (think any top down game/rts). I start by setting the vector location of the left mouse button when pressed and then setting the vector location when the left mouse button is released. However I can’t get the mid vector location between these. When I do a line trace from the camera (floating above the scene) to the mid point (2nd point - 1st point) it shows me a random location.
I believe its because if the locations contain a minus in any of the x, y or z axis it gives a incorrect result.
No I know there is the rama series of add-ons that will no doubt be mentioned, I’m really trying to understand how to do it without it. No sense in just accepting I can’t do it and skipping it.
Any help or even an full example of a drag box in blueprints would be a great.
2nd point - 1st point provides you with the directional vector 1st → 2nd. If you add this one to your 1st vector you will again get your second vector.
To get the middle point you have to do this ((2nd - 1st) / 2 + 1st). 2nd - 1st to get the vector between those two vectors / 2 to get the middle and + 1st to add it to the location of your first vector. Otherwise it will just start at 0, 0, 0 and therefore give a wrong result.
You might want to take a look at these:
Vector math is everything but UE related even though it’s very important for quite a large amount of stuff you want to do. Kahn academy has quite a few pretty good videos about different vector operations and you can even train it on their website!
Best for what? Lerp is for linear interpolation and it’s used for interpolating a value over a period of time. So this method is best to interpolate a value over a period of time between two vectors. If I just need to find a center point between those two, (v1 + v2) / 2 is much better: simpler algorithm, faster, easier to understand.