How to resume animation from last frame

Hi, I am doing a ladder tutorial for my viewers on youtube, and I want to be able to teach them on how to make the ladder script I’ve made using animations more advance. The thing is that when I stop moving when I am on the ladder,and then start moving again, the player’s ladder animation goes to the first frame (or down to the ground actually), but I want to be able to resume the animation from the current frame in the animation.

My question is: How can I resume the animation from the current frame?

Here’s my ladder script (this may not be the best script) :

var Player : GameObject;
var CanClimb : boolean = false;


function Update () {

if(Input.GetKey(KeyCode.W)){ if(CanClimb == true){ Player.animation.enabled = true; Player.animation.Play("ClimbLadder"); } else Debug.Log("Player can't climb"); } if(!Input.GetKey(KeyCode.W)){ if(CanClimb == true){ Player.animation.enabled = false; } else Debug.Log("Player can't climb"); }




}



function OnTriggerEnter (other : Collider) {

if(other.gameObject.tag == "Player"){
CanClimb = true; 
}



}


function OnTriggerExit (other : Collider) {

if(other.gameObject.tag == "Player"){
CanClimb = false;
}




}

Hi Richard

First-of all Unity animation play on time based. if you want to start animation from any particular frame you have a idea that frame came on what time. after that you can used normalised time of animation for to stop or start from particular time.

you can’t access frame no of animation in script.

void Start()
{
Animator animator = gameObject.GetComponent();

        // The time your want to resume to.
        float normalizedTime = 0.4f;
        //
        // Summary:
        //     Plays a state.
        //
        // Parameters:
        //   stateName:
        //     The name of the state to play.
        //
        //   layer:
        //     Layer index containing the destination state. If no layer is specified or
        //     layer is -1, the first state that is found with the given name or hash will
        //     be played.
        //
        //   normalizedTime:
        //     Start time of the current destination state. Value is in normalized time.
        //     If no explicit normalizedTime is specified or value is float.NegativeInfinity,
        //     the state will either be played from the start if it's not already playing,
        //     or will continue playing from its current time.
        //
        //   stateNameHash:
        //     The AnimatorState fullPathHash, nameHash or shortNameHash to play. Passing
        //     0 will transition to self.
        animator.Play(0, -1, normalizedTime);
    }