Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mixing mecanim with legacy animation

Discussion in 'Animation' started by Rusfighter, Mar 21, 2015.

  1. Rusfighter

    Rusfighter

    Joined:
    Jan 18, 2014
    Posts:
    60
    Hello guys,

    I am currently creating an endless runner (subway surf) kind of game. I am using the run mecanim animation without root motion applied for the running effect. Now i want to let my character side jump (just like in subway surfers by swipe) but i do not have any idea how to create this.

    My character is fixed in the z-axis and only should move in x (side right/left) and y axis only.

    I do not have any side jump animations nor i do not how to make them.

    Is it possible to use mecanim animation for the jump/run animations and using at the same time legacy animation to let him move among x/y axis?

    Many thanks,

    Ilija
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,531
    You can't mix Mecanim and Legacy on the same bones. In your case, here are a couple ideas:

    1. Grab some side jumps from Unity's free raw mocap data.

    2. Or move side-to-side in script. If you have a forward jump, play it. At the same time, move the character to the side using, for example, CharacterController.Move().
     
    theANMATOR2b likes this.
  3. fedorenkosergiy

    fedorenkosergiy

    Joined:
    Jun 11, 2014
    Posts:
    8
    It is possible to mix Mecanim and Legacy animation. But you have to update legacy animation state manually.

    AnimationState state = animation[animation.clip.name];
    state.weight = 1.0f;
    state.enabled = true;
    state.time = myTime;
    animation.Sample();
     
    Last edited: Jun 4, 2015