Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Transitioning with Unity Sprites.

Discussion in 'Animation' started by Mervill, Dec 6, 2013.

  1. Mervill

    Mervill

    Joined:
    Jul 20, 2012
    Posts:
    16
    Hello!

    I am using an Animation Controller to manage my character's animation states, the character is 2D so the animations deal with switching the current sprite.

    I have two walk cycles, a 'normal' walk cycle and a 'bloodied' walk cycle, when I transition between them I'd like the current 'frame time' to be preserved, so if it's on frame 12 of the normal animation, the transition should start the bloodied animation on frame 12.

    I've managed to accomplish this in a script using normalizedTime:

    Code (csharp):
    1.  
    2. bodyController.SetBool("Bloodied",true); // Set the state bool
    3. // Force the current time position to be preserved.
    4. AnimatorStateInfo inf = bodyController.GetCurrentAnimatorStateInfo(0);
    5. bodyController.Play("WalkBloodied",0,inf.normalizedTime);
    6.  
    But I'm wondering if I can achieve the same with a transition in the animation controller.

    Thanks!
     
unityunity