Hi. I’m trying to figure out how to calculate angle between 2 points.
“Object 1” and “Object 2” are inside the widget, and are randomly in different coordinates…
Here’s a picture that shows what I’m trying to calculate (it’s the angle of the red line:
I want to make the blue object turn in that direction wherever the “Object 2” is. above, below, left, or right. Currently, the “blue” object is turning directions, but only rarely in the correct direction.
Uh i do not see any angle in your pictures, not sure which one you want calculate.
Yes using dot product > Acos is good idea. However you need to draw those two vectors that make your angle, also yes never forget to normalise them dot product works on normalized vectors.
PS.
there is look at node in blueprints , if you use 2 locations and set Z=0 in both you can use it for 2d calculations.
do not confuse location of actor with relative location between those two. Make triangle, calculate sides, then use dot product to calculate rotation.
since this is just 2d you can use pitagoras and trigonometry to find rotation, you need single rotation there
It’s red line in that picture. I wanted to calculate angle (or rotation) of that red line that comes between 2 objects and it’s angle here is about 50°.
I’m pretty sure “Look At” doesn’t work with Widget objects.
This worked better, but my object was randomly upside down, even with our without the “+180”.