Search Unity

How to pause an animation?

Discussion in 'Animation' started by sovichmarcus, Sep 19, 2021.

  1. sovichmarcus

    sovichmarcus

    Joined:
    Feb 19, 2021
    Posts:
    2
    So I'm currently trying my hand at a full game for the first time and I want the game to be similar to the Zelda Gameboy games, as part of the aesthetic I don't want my player character to have an idle animation but I want the animation to simply pause where it was before the player stopped moving, does anyone know how to do this?
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    Hey,

    You have to set the animator speed to zero. To un-pause, set the speed back to one. Get a reference to the animator and then set its speed property:

    Animator anim = GetComponent<Animator>();

    anim.speed = 0f;

    anim.speed = 1f;
     
    Mozzarella98 likes this.