Help a newbie get through the basics.
How to find the distance between two points in 3D space?
How do I write (calculate) a mathematical expression? For example: var1 * cos (var2) + var1 * sin (var2).
Vector - vector then get Vector length
thereās also a built in function which does the same thing
You can actually just write it:
What is a vector? Point coordinates?
yes 3D coord, you can read this doc for ue4 basic terms: https://subscription.packtpub.com/book/game_development/9781784394905/1/ch01lvl1sec18/the-2d-and-3d-coordinate-systems
In UE, a vector is just a point. But there is also the implied distance from the origin. So it is also a vector in the traditional senseā¦
Now I understand, thanks.
Another stupid math question. I just canāt understand. There are two variables of the rotator type
R1 = (0, 0, 0)
R2 = (90, 0, 0)
As you can see, they are perpendicular to each other. I apply a random (I donāt know which) transformation to the first rotator and it becomes, for example
R1 = (23, -78, 55)
How do I calculate the transformation for the second rotator so that it remains perpendicular to the first?
Donāt try and do it in your head, it will explode, use the compose rotators node ( order matters ).
I do not understand, you can tell in more detail.
Thank you, this is what I need. Now my AAA project is saved.
Geez. Stakes are high here!
If youāre concerned about the actual math behind the distance between two Transforms, then hereās that educational answer.
The Pythagorean distance between two Translation Vectors is:
ā ( ( v2_x - v1_x )² + ( v2_y - v1_x , 2) ² (v2_z - v1_z )² )
to actually get a float value d out of this, is very tricky because FTransform is a struct, and well, contains some other data, but it can be done, because youāve to apply both scale and rotation to bring that down to what you need, which is an Vector, resulting in a Real Vector, and then do the distance calculation.
Hereās that solution in raw blueprint nodes, taking in two actors as a reference, and calculating the Pythagorean distance between them (d), returning a float that explicitly tells you how far away two objects are from each other. If thatās all the information you need, than this oneās for you.
GetDistance Blueprint
How to break out the transform, then apply the scale and the rotator to get the real vector.
And finally, Pythagorean Theorem, with all 6 components from the output of the real vector calculations.
This probably overcomplicates matters, but my answer here is more of a āneed to knowā thing, about the math going on under the hood. You should get acquainted/comfortable with trigonometry, it is of course used a lot in calculations like this.
If, additionally, youād like to get super technical and actually use the center of an actor and not its root componentās pivot to do the distance calculation, you can:
Drop the original Actorās transform, and use a GetActorBounds node, which returns the center of an Actor with all of its components in world space using a bounding box, and use that.
In most āAm I too far away, or close enough?ā state checks as well, the negative sign isnāt needed. My last post for accuracy defines how, but in here, is probably the way youād use (d), as an absolute value:
But do you see where our new problem is? Weāre now applying FRotator and FScale3D to the center of the FBoxExtents. Should we do this? No. Because GetBounds is a collission-friendly and does that for us! So, can we skip it? **** yes.
Which does result in this bad boy:
No longer need to bother with FRotator or FScale3D at all thanks to Box Extents doing all that internally during a GetBounds call.
Heās not the most efficient (better ways, line traces being one) but he makes the mathematician happy.
Final Notes
Collision does not have to be enabled to do a GetBounds call, so these calculations stay independent of Physics, which is nice, long as you leave the booleans on the input nodes alone.
I would advise leaving āGet Child Actorsā alone unless you have actors chained together for something special, and need the child actors to be taken into account, too. This is usually only for edge cases.
Of course, when I post this, I donāt set up my exec nodes correctly, so hereās that ādonāt yell at meā post (lol)
Thank you, this is very interesting. I am familiar with the basics of trigonometry. I understand that the Pythagorean theorem is used to calculate the distance between points. I just donāt understand what the GetActorBounds function does?
This actor has 2 scene components (white sphere + white box), its bounds look like so - the yellow frame:
Visualising things with debug nodes helps a lot - worth exploring.
Origin is the coordinates of the center of the box.
Box Extent - coordinates of what? Or is it the dimensions of the box?
If my actor is a mannequin, then the center will depend on the position of the body and will change all the time. Right?