if animator state=x

Hi.
I want to only instantiate my poop when the current animation state is “poopState”…
This is my current script:

var animatorController : Animator;
var poopObject : Transform;
var poopSpawn : GameObject;

function Start (){
	if(!networkView.isMine){
		enabled=false;
	}
}

function Update (){
	if(Input.GetButtonDown("Poop")){
		instantiatePoop();
		animatorController.SetBool("poop", true);
	}else{
		animatorController.SetBool("poop", false);
	}
}

function instantiatePoop (){
	yield WaitForSeconds(0.5);
	Network.Instantiate(poopObject, poopSpawn.transform.position, poopSpawn.transform.rotation, 0);
}

Thanks.

First you need an enum declaration

var State:PoopState = PoopState.AnyState;

then you use it in the Update:

function Update (){
    if(Input.GetButtonDown("Poop")&& State = PoopState.PoopGoing){
       instantiatePoop();
       animatorController.SetBool("poop", true);
    }else{
       animatorController.SetBool("poop", false);
    }
}