Hello,
I´m developing a Profiler Tool in Unity VR and I have a problem where I need help. I will simplify my problem so it’s easier to understand.
I have two primitive cubes, let’s say cube A and Cube B. Cube A has always a Rotation of Vector3.zero. Cube B appears after a button click with a little distance in front of the Camera.
Now I want that Cube B has the same relative Rotation to my Main Camera (Camera that its attached to the head mounted display) as Cube A.
As Example: Imagine Cube A is at position (0,0,0) an the main Camera at (2,10,-10). Cube B (2,10,-9) is in front of the camera .
Now when I look at Cube B, I have the same “perspective view” as if I look at cube A.
One of my ideas was to calculate the DeltaRotation of the forward Vectors:
Vector3 lookDirectionCubeA = Camera.main.transform.position - cubeA.transform.position;
Vector3 lookDirectionCubeB = Camera.main.transform.position – cubeB.transform.position;
Quaternion deltaRotationCubeA = Quaternion.FromToRotation(CubeA.transform.forward,
lookDirectionCubeA);
Quaternion deltaRotationCubeB = Quaternion.FromToRotation(cubeB.transform.forward,
lookDirectionCubeB);
Quaternion diff = deltaRotationCubeB * Quaternion.Inverse(deltaRotationCubeA);
And use the lookAt Method:
Vector3 forward = cubeB.transform.forward;
forward = diff * forward;
cubeB.transform.LookAt(forward);
But that doesn’t seem to work.
Thanks for every idea and help 
Edit: For better understanding i took a view screenshots:
First img: Cube A and B have the same world Rotation.
Second Img: Now i want the cube B looks at the camera exact like cube A (I tried to rotate cube B in the Inspector for the screenshot)