I've answered a few flavours of this before.
The basic idea is to chain together two rotations: one that takes the axes you want to align and points them along z+ and y+ respectively, and then the standard LookRotation to take z+ and y+ to the desired destination axes.
For a straight 3D analogue of LookRotation that positions the x+ axis instead of z+, but still treats y+ the same way as ordinary LookRotation:
Quaternion XLookRotation(Vector3 right, Vector3 up = default)
{
if(up == default)
up = Vector3.up;
Quaternion rightToForward = Quaternion.Euler(0f, -90f, 0f);
Quaternion forwardToTarget = Quaternion.LookRotation(right, up);
return forwardToTarget * rightToForward;
}
Or, to keep an object locked in 2D with z+ forward, as in the second link above:
Quaternion XLookRotation2D(Vector3 right)
{
Quaternion rightToUp = Quaternion.Euler(0f, 0f, 90f);
Quaternion upToTarget = Quaternion.LookRotation(Vector3.forward, right);
return upToTarget * rightToUp;
}
Quaternion.RotateTowards
. Or, if you want an exponential ease-out behaviour similar to what you have now but consistent at different framerates, set your interpolant toMathf.Pow(fractionRemainingAfterOneSecond, Time.deltaTime)
. Also, be careful intermixing localRotation and rotation - this can give unexpected behaviour when the object has a rotated parent. \$\endgroup\$