Why does animation clobber my positioning code?

Okay so I have two objects in my world, one with a looping animation, and one without. The below code is supposed to take the object and move it in front of my avatar. I attach the below code to both objects and the object without the looping animation does exactly what was intended. The object with the looping animation stays in some random place in the world. If I turn the animation off in the inspector the object works as it’s supposed to, put it back on and the problem occurs again. Any ideas?

var objectToFollow;
var ufoVisible = false;

function Update () 
{
    if(gameObject.Find("localPlayer")==null)
    {}
    else
    {
		if(ufoVisible)
		{
			objectToFollow = GameObject.FindWithTag("Player").transform;
			transform.rotation = objectToFollow.rotation * Quaternion.Euler(0,-90,0);
			animation.Play("Take 001");//added
		}
		else
		{
			objectToFollow = GameObject.FindWithTag("Player").transform;
			transform.position = objectToFollow.TransformDirection(Vector3.forward * 4) + objectToFollow.position;
			transform.rotation = objectToFollow.rotation * Quaternion.Euler(0,-90,0);
			animation.Stop("Take 001");//added
		}
    }
	
	if(Input.GetKeyUp("u"))
	{
		if(ufoVisible)
		{
			ufoVisible = false;
		}
		else if(!ufoVisible)
		{
			ufoVisible = true;
		}
	}
}

It’s because when animating, you should always keep the model at the pivot, because the animation plays in local space with the model. You’ll just have to adjust the numbers until it fits right, or reanimate.

I may be way off here, but an idea: Seems that animation curves affect the transform. So does the code, but the animation is ‘winning’ this fight. What if you reparent the object, with the animation curves on the child, and the animation code on the parent (or vice-versa)?