# Weird Animation Behavior in Unity

I discovered a weird animation bug and have no idea how to solve it. Below you find the script I attached to my humanoid character.

using UnityEngine;
using UnityEngine.AI;

public class PlayerCharacter : MonoBehaviour {

private Animator anim;
private NavMeshAgent agent;

void Awake()
{
this.anim = GetComponent<Animator>();
this.agent = GetComponent<NavMeshAgent>();
}

public void Kill()
{
}

void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
Kill();
}
}

{
}
}


My character makes use of the NavMeshAgent and can walk around and idle - everything works fine. But if I want to kill the player the dead animation loops continuously. This also happens if I change the death animation.

This is my AnimationController:

As you can see, the transition has the condition "Death" with is set to true in the Kill() method. The code for walking and idling in combination with the NavMeshAgent is similar, but the script shown above doesn't work as expected and I have no clue why the animation starts to loop continuously (which looks a bit funny btw). Additionally the animation is not played to end, it restarts after a few frames.

Any ideas? I could also post a video of the behavior if it would help. Thanks in advance! :)

Select the Unarmed-Death1 state, and if you double-click on the animation (motion) in it, you should see a Loop Time option. Just uncheck that and it should stop looping.