I have a single default state in my animation controller named SpikeBrightFloor.
This animation state has two frames which I wish to either play forwards and stop or play backwards and stop depending on a flag called isDeadly.
This is what I am currently doing:
var animator = GetComponent<Animator>();
var info = animator.GetCurrentAnimatorStateInfo(0); // Only one state
isDeadly = !isDeadly;
if (isDeadly)
{
// Play forwards
animator.playbackTime = 0f; // Beginning of state
animator.speed = 0.1f;
animator.Play("SpikedBrightFloor");
}
else
{
// Play backwards
animator.playbackTime = info.length; // End of state
animator.speed = -0.1f;
animator.Play("SpikedBrightFloor");
}
I can get the state and I can get the length of the state and I can set the animator parameters but the animation never seems to play. What is going wrong?