Unity 5 - Playing animation from AnimationState forwards and backwards has no effect

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?

Solved:

Set animator speed to 0f when initialising the script.

        var animator = GetComponent<Animator>();
        animator.speed = 0f;

you don’t need to set playbackTime, this is only needed when you do record and playback your recorded animation.

animator.Play is enough to play “SpikedBrightFloor” from the beginning.