Play an animation of animator once (only)

private Rigidbody rb;
public Animator anim;
public float timer;

// Use this for initialization
void Start () {

	rb = GetComponent<Rigidbody>();
	anim = GetComponent <Animator>();
	anim.SetBool ("Animate", true);

I have an animation in my animation controller.
As you can see I put it into Start().
Why does it keep playing infinitelly? I thought it should stop after the very first loop (given that it’s in Start).
What’s the quickest way to make it stop after the first playthrough?

Thanks.

Make your animation clip "Loop Time " to FALSE…

You should to use Trigger instead of Bool.

A trigger parameter is a bool parameter that gets reset to false when it has been used in a transition. For state machines with multiple layers, the trigger will only get reset once all layers have been evaluated, so that the layers can synchronize their transitions on the same parameter.

You can set trigger variable using SetTrigger() method. So your Start() method will look like:

rb = GetComponent<Rigidbody>();
anim = GetComponent <Animator>();
anim.SetTrigger("Animate");

However if you stick to use Bool. Then you have to reset Animate to false in some other method which is called just after Start(). Simple technique is using Invoke() method in which set Animate to false. For example:

void Start()
{
    rb = GetComponent<Rigidbody>();
    anim = GetComponent <Animator>();
    anim.SetBool("Animate",true);
    Invoke("SetAnimateFalse",0.001f);
}
void SetAnimateFalse()
{
    anim.SetBool("Animate",false);
}