How to do 2D aiming

I am trying to make a 2D game, and i am currently working on a missile that smoothly aims for a another object. My current code looks like this:

Vector3 targetPosition = new Vector3(missileTarget.position.x, missileTarget.position.y, transform.position.z);

Quaternion rotation = Quaternion.LookRotation(targetPosition - transform.position, Vector3.back);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping);

The problem is that Quaternion.Slerp rotates the object in all 3 rotation axis, even trough both the missile and the target is on the same 2D plane. As it is actually shorter sometimes, problem is of course that my game is a 2D game. How can i make sure the missile will be rotated in the X rotation axis only?

Use Quaternion.AngleAxis to rotate on the axes individually. Try using that, but I am not sure that this is going to solve your problem completely. Is the game actually projected onto the 2D screen plane or are all the aspects just operating at the same Z coordinate for example? If it's the former, you might get slightly incorrect results with rotations.

An example of this would be

transform.rotation = Quaternion.AngleAxis(30f,transform.up) * transform.rotation;

to take the object at its current rotation and rotate it 30 degrees around it's local up axis. You could use Vector3.up for the world up axis. To use Slerp, just store the new rotation and Slerp to it instead of setting it directly.

Just lock the other two axis. Add something like this to the end of Update:

transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, 0, 0);