if (gameObject.GetCurrentAnimatorStateInfo(0).IsName("Walk Left")) {
// Check if animation is walking left, so that left idle animation can play
}
if (gameObject.GetCurrentAnimatorStateInfo(0).IsName("Walk Right")) {
// Check if animation is walking right, so that right idle animation can play
}
if (gameObject.GetCurrentAnimatorStateInfo(0).IsName("Walk Up")) {
// Check if animation is walking up, so that up idle animation can play
}
if (gameObject.GetCurrentAnimatorStateInfo(0).IsName("Walk Down")) {
// Check if animation is walking down, so that left down animation can play
}
I’m trying to use an idle animation per direction.
I tried this code in the UPDATE void, but it returns
Type UnityEngine.GameObject' does not contain a definition for
GetCurrentAnimatorStateInfo’ and no extension method GetCurrentAnimatorStateInfo' of type
UnityEngine.GameObject’ could be found. Are you missing an assembly reference?
How do I fix this code?