Search Unity

Blending/Crossfading animations with leganimator (Locomotion System)

Discussion in 'Scripting' started by Zaddo, Aug 5, 2012.

  1. Zaddo

    Zaddo

    Joined:
    May 19, 2012
    Posts:
    18
    I am having all sorts of problems Blending/Crossfading animations with the locomotion system. Game style is a FPS.

    I thought I would post my problem here as a last ditch try that some good person will assist. Otherwise i'll have to ditch the locomotion system.

    Note: If I turn off legAnimator, my animation work perfectly. Except of course the legs don't move as my character moves.

    Also, leg animator is working beautifully for leg movements, running, walking, turning, strafe. It continues to work well when I crossfade my other other animations.

    My code just doesn't work with the locomotion system running. I have searched the forums and cannot find an answer to my problem.

    Issues:

    1. If I am running, Crossfading to reload/shooting/etc runs my animation at a fast speed. This makes it look very ugly. I think it the locomotion system might be increasing speed on all current playing animations, or unity can't run the leg animations at a different speed to the upperSpine animations so it speeds up my reload animation. Code extract below is for running reload animation:


    anim.animation["Reload_standing"].AddMixingTransform(upperSpine);
    anim.animation["Reload_standing"].wrapMode = WrapMode.ClampForever;
    anim.animation["Reload_standing"].layer = 3;
    anim.animation["Reload_standing"].speed = 1.0f;
    anim.animation["Reload_standing"].time = 0;
    anim.animation.CrossFade("Reload_standing", 0.1f);
    anim.animation["Reload_standing"].weight = 1f;
    StartCoroutine(ResetReload(1.6f));

    private IEnumerator ResetReload(float t)
    {
    yield return new WaitForSeconds(t);
    anim.animation["Reload_standing"].weight = 0f;
    }

    2. My dieing animation loops and runs at a faster speed. (note: turn off leganimator and it clamps on final frame and plays at proper speed.)

    anim.animation["Die"].weight = 1.0f;
    anim.animation["Die"].time = 0.0f;
    anim.animation["Die"].wrapMode = WrapMode.ClampForever;
    anim.Play("Die", AnimationPlayMode.Stop);
     
    Last edited: Aug 5, 2012
  2. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,723
    Did you put the reload/shooting and die animations in the Ungrouped group in the LegController as described in the section of the Locomotion System docs called "Blending and Cross Fading"? If not, you might want to try that.

    Rune
     
unityunity