Search Unity

Animation transition on the same frame

Discussion in 'Animation' started by Meatb0y, Mar 8, 2019.

  1. Meatb0y

    Meatb0y

    Joined:
    Jan 25, 2015
    Posts:
    43
    Hi everybody

    I've two 2D animation : walking and running with the same number of frame and a button to switch between them, i want that if my walking animation is on a frame, the transition switch immediately on the same frame to the running animation if i press my button. I can manage to do it with a script but i would like to do it with the animator.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    I believe the easiest way to do it would be to put them both in a blend tree and use a parameter to switch between them.

    Another way to do it would be to select both states and set a parameter to control their normalized time. Though that might mean you need to always update the time yourself rather than being able to simply set it when you switch and let it run on its own (I've never actually used that feature so I don't know).

    If you're interested in a system that gives your scripts much more flexibility to control animations, my Animancer plugin would let you do this very easily (there's a link in my signature below). You could just get the time from one animation and set it on the other without messing around with any parameters or setting anything else up beforehand.