How do I make my gameobject rotate smoothly towards target?

I have a transform which is the player’s head bone, and I want to rotate it towards the opponent smoothly. Right now, with the following code, the player’s head rotates towards the opponent as expected, but it is not smooth. As soon as the condition is met, the player’s bone rotation just jumps to the expected rotation. I want it to look smooth:

Vector3 look = GameObject.FindGameObjectWithTag("Opponent").transform.position-bone.position;
 bone.forward = look;
 bone.localEulerAngles = new Vector3(bone.localEulerAngles.x, 8, 0); //to maintain the other axis from changing //x is apparently the local axis in this case that makes the player's head rotate left to right

I could suggest you to try this way:

Quaternion lookRotation = Quaternion.LookRotation((target.position - transform.position).normalized);
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, 5f * Time.deltaTime);

“transform.rotation” and "transform.position" is the object you’re trying to rotate, and lookRotation’s target.position is the “Opponent” i suppose.


Not sure if this is what you wanted but i think you should have it so the head will rotate slowly each frame until the desired target is reached.