Script over animation movement

Hello guys
So i been trying to make some simple Ai for my enemy in Unity and i run into a problem that i cant solve
function LateUpdate () {

if(Vector3.Distance(player.position, this.transform.position) < 20) {

var direction : Vector3 = player.position - this.transform.position;
direction.y = 0;

this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), 0.1f);
if(direction.magnitude > 2) {

	this.transform.Translate(0,0,0.05f); 
	


}
	else if (direction.magnitude <= 2) { //&& direction.magnitude > 2) {
	this.transform.Translate(0,0,-0.05f);
		//anim.SetTrigger("Atakuoja");

}
}
}

So this simple script is bassicly checking does enemy see the player if he does he moves until he is 5 blocks away i wanted him from that spot to attack the player well jump on him (its a wolf) i tried to script it and i ran into countless problems so i thought hey i can just set trigger to activate animation when he gets close enough. Problem is if i create attack animation (iam using low poly model made by myself in blender its novice model no bones no nothing etc. ) the script doesnt affect wolfs movements anymore so bassicly if animation has parameters for position script wont be able to change wolves position so could i get some help or at least some kind of link to tutorial for my issue

script Picture: Imgur: The magic of the Internet

“this”…doesn’t that refer to the script itself and not the gameObject that contains the script? That is how I always use “this”. like “this.enabled = false”, when I want to disable the script. Or " Destroy (this)" when I want to destroy the script.Does the wolf have a navMesh Agent on him? This is a C# script below that may or may not work as is but it’s a snippet of a working script I have on one of my enemies

public float damping;
NavMeshAgent agent;
  if(Vector3.Distance(transform.position,Player.position) == 20)
		{
			var rotation = Quaternion.LookRotation(Player.position - transform.position);
			transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
    
    if(Vector3.Distance(transform.position,Player.position) == 5)
anim.SetTrigger("attack")
agent.SetDestination(Player.transform.position);