Object makes random jumps in rotation

![alt text][1]I made this copy rotation script where it takes a desired object and copies its rotation to the object that the script has. It works, but then once I added an influence variable (percentage value that determines how much it copies the rotation) I noticed a problem. It seems like when influence in set somewhere between 0 and 1 then if I rotate the copyObject too far (), the object will make a jump in rotation, and then if I go too far again, then it will make another jump (and so on).

Here is the script

public class RotationConstraintCD : MonoBehaviour
{

[SerializeField]
bool freezeX;
[SerializeField]
bool freezeY;
[SerializeField]
bool freezeZ;

[SerializeField]
[Range(0, 1)]
float influence;

float desiredX;
float desiredY;
float desiredZ;

float finalX;
float finalY;
float finalZ;

[SerializeField]
Transform copyTransform;

void Update()
{
    if (!freezeX)
    {
        desiredX = copyTransform.rotation.x;
        finalX = (desiredX * influence);
    }

    if (!freezeY)
    {
        desiredY = copyTransform.rotation.y;
        finalY = (desiredY * influence);
    }

    if (!freezeZ)
    {
        desiredZ = copyTransform.rotation.z;
        finalZ = (desiredZ * influence);
    }
    

    transform.rotation = Quaternion.Euler (new Vector3(finalX, finalY, finalZ));
}

}

transform.rotation is a quaternion. You’re taking quaternion values and creating a vector3 with them. Try using transform.rotation.eulerAngles.x/y/z instead and see if that helps.