Search Unity

Simple Animation Transitions

Discussion in 'Animation' started by JP_Ferreira, Dec 9, 2013.

  1. JP_Ferreira

    JP_Ferreira

    Joined:
    Nov 15, 2012
    Posts:
    5
    Hi guys!

    For context think of a motorbike game.

    I have a bone animation character that tilts left on key left press, right on key right press, and straight if none key pressed.

    The problem is, when i press one of the keys, the animation allways start from the straight position, that's ok, but if i want him to tilt right and then tilt left? What do i need to do to go from one animation point to the other without causing it to start from the straight position?

    Taking the bike example if i'm leaning left and the next corner is to the right, how can i let unity know that the player needs to go all the way to the straight position and only then tilt right?

    Thank you in advanced!

    If the answer is too big, please point me to a tutorial or something where i can see a similar problem solved!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Try putting all the animation clips in a blend tree that blends on a Float parameter, where -1=tilt-left, 0=straight, and +1=tilt-right.

    When the left key is pressed, smooth the parameter to -1. When the right key is pressed, smooth it to +1. If no keys are pressed, let it smooth back to 0.
     
  3. JP_Ferreira

    JP_Ferreira

    Joined:
    Nov 15, 2012
    Posts:
    5
    First of all thank you!

    I'm a newbie on animation in unity! I have to use the animator component?

    Thank you!
     
  4. mikejkelley

    mikejkelley

    Joined:
    Dec 20, 2011
    Posts:
    43
    Yes, this would all be accomplished in mecanim.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    If you're using the legacy animation system, you could write your own blend tree code (see Mixamo's RMCv2 for some example source code) or use SAGE, which is like Mecanim for the legacy system.