I am using this tutorial as guide - YouTube but it calls AnimatorStateInfo.name which seems to have been removed from the class.
I want to call my “Atak2” if Atak_Key is pressed during “Atak1”:
PseudoCode:
if(currentInfo.name == "Atak1" && Input.GetKey("Atak_Key"))
{
//Set bool on mecanim to call animation Atak2
}
How to do it now?
How About using something like this:
if( anim_Animator.GetCurrentAnimatorStateInfo(0).IsName("MyAnimationName"))
{
//Do something if this particular state is palying
}
This Function returns true when the string is the same as teh StateName you play currently.
Else false.
jwinn
November 25, 2012, 5:38am
2
Check out the latest Mecanim tutorial download, which has changed code since the beta. I was just dealing with integrating all the mecanim animator changes today.
Here’s an example of how they set it up. This is assuming your base layer is named “Base”:
static int atakState = Animator.StringToHash("Base.Atak1");
void Start (){
anim = GetComponent<Animator>();
}
void FixedUpdate ()
{
currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
if (currentBaseState.nameHash == atakState){
Debug.Log("Do Stuff Here");
}
}