I have three objects in total, 2 cubes and one billboard. The 2 cubes are placed on the outside and then the billboard is placed in the middle by taking the positions of the 2 cubes and placing in between all the time. My headache now is to also apply the correct rotation that would occur between these 2 cubes, and so far search engines have come up empty so I thought I’d try it here…
I’ve managed to make it work somewhat by having centered child objects on the cubes and use LookAt() between them and use the rotation from that on the billboard. However this makes the billboard face the wrong direction, a temporary fix has been to write +90 degrees on the y-angle of the rotation but that breaks the rotation from working as intended.
My current code:
Transform leftcube;
Transform rightcube;
leftcube.LookAt(rightcube);
transform.rotation = Quaternion.Euler(leftcube.rotation.x, leftcube.rotation.y + 90, leftcube.rotation.z);
//Script attached to the billboard
An illustration of what I’m trying to achieve:
The red line illustrates the line drawn from the two cubes where the rotation in the center should be retrieved and applied to the billboard.