Well there is a method on Quaternion to create a rotation from 2 vectors:
Itâs LookRotation which takes a forward and an up.
You have an up and a right⌠of course mathematically this would be enough, but why do all the complicated maths of quats, when we have this forward/up version gifted to us in the lib.
So all we need is to get a forward from the right/up.
And we do that by the cross product of the right/up:
So⌠cross right/up to get the forward. Then pass forward/up to the Quaternion.LookRotation. And thatâs our needed rotation.
[edit]
Sorry I should point out order of operations matters on Vector3.Cross, as the link talks about the âhandednessâ of Unity.
So youâre going to want to pass your ârightâ as the âlhsâ (first parameter), and your âupâ as the ârhsâ (second parameter).
If one does it backwards⌠all you get is -forward rather than forward. So if my code results in backwards positioning⌠well, I did my order of operations backwards. None of us are perfect.