# Unity look at rotation on one axis only problem

Hey I would like an object to look at another object only at one axis, when I rotate the white cube all around the gray cube (gray has look at script), the gray cube flips as soon as the target passes the middle and is on the right side. How can I fix this, so that rotation is normal.

Below is when the cube (target, white).

Below is what happens when the cube (target) passes on the other side, as you can see by the texture the gray cube flips horizontally.

Below is how it should be (texture shows difference)

Code:

    Quaternion lookAngle = Quaternion.LookRotation(targetPos, Vector3.up);


Vector3 dif = targetPos - transform.position;