- Home /
Question by
mustafa · Jan 10, 2016 at 11:20 PM ·
animationanimatormecanimstate-machine
Mecanim. Why cant I get current state name?
Why nothing of the API is exposed in Mecanim. I simply want to get the name of current state. Is there a valid reason as to why this not available?
Comment
Answer by hulahoolgames · Jan 10, 2016 at 11:51 PM
IEnumerator startAnimationCoroutine(string stateName) {
bool targetStateReached = false;
while(!targetStateReached) {
if(!m_CarAnimator.IsInTransition(0)) {
targetStateReached = m_CarAnimator.GetCurrentAnimatorStateInfo(0).IsName(stateName);
}
yield return null;
}
// animation finished playing, time to snap to grid center
m_AnimationEndTime = Time.time;
}
This is a piece of code I use in my project to check the animation state my AI vehicles are in. You can use this to determine the same.