Rotate specific axis to look at camera

Hello, I’m struggling with rotating an object to look at a camera.

I have an object which can be any orientation. I have methods to choose which Axis you want to be the “forward” direction(.i.e face the camera) and which axis to be the “Up” direction.

I can get 1 of these directions to work but not both. The way I am trying it is as so:

private Vector3 GetLookDirection ( DirectionAxis direction, Transform t )
        {
            switch ( direction )
            {
                case DirectionAxis.Green:
                    return t.up;
                case DirectionAxis.NegGreen:
                    return -t.up;
                case DirectionAxis.NegRed:
                    return -t.right;
                case DirectionAxis.Red:
                    return t.right;
                case DirectionAxis.Blue:
                    return t.forward;
                case DirectionAxis.NegBlue:
                    return -t.forward;
                default:
                    return t.forward;
            }
        }

void TestFunction()
{
  transitionTransform.forward = GetLookDirection(DirectionAxis.Red, transitionTransform);
transitionTransform.up = GetLookDirection(DirectionAxis.Blue, transitionTransform);

}

transitionTransform should then contain the target rotation I can lerp to. This doesn’t work (obviously) as when I modify the forward it will also modify all other directions.

I’ve also tried things like:

transitionTransform.rotation = Quaternion.FromToRotation(Vector3.forward,GetLookDirection(DirectionAxis.Red,transitionTransform) * Quaternion.FromToRotation(Vector3.up,GetLookDirection(DirectionAxis.Blue,transitionTransform);

Which seems to yield the same result.

Basically, I want to flip the up and forward axes to point towards directions that I specify. I need some help, thanks!

Quaternion.LookRotation(forward, up)

the transitionTransform Transform is an object which another object will orient to(through Lerp).

This other object will have a script which allows someone to choose which axis is “forward” i.e. will face the camera, and which axis is “up”.

So the transitionTransform needs to switch around it’s axes based on what settings are chosen. So if the user wants to x axis to point toward the Camera, the x axis should then point to the current z direction, etc.

LookRotation() doesn’t seem to solve the problem, I was using it like so:

transitionTransform.rotation = Quaternion.LookRotation(Vector3.Right, Vector3.Forward );

Is that in correct?