- Home /
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.
Comment
Best Answer
Answer by fafase · Feb 07, 2013 at 07:20 AM
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);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613092303im_/https://answers.unity.com/themes/thub/images/avi.jpg)