Dance animation toggled with X key (Unity Animation parameter with third person character controller)

Finally got the animation to trigger on pressing X, though it was impossible to find specific info online.

I initially wanted to just have the animation play once on X, but I ran into the problem of how to set the bool parameter that activated the animation back to false. 

Eventually, I settled on have the X key toggle the animation, then it was just a matter of having it transition back to idle. The animation is set to loop, so will keep dancing until you toggle it off.

// Dancing stuff

private int _animIDDance;

private bool danceBool=false;

...

private void Dance()

{

if (Input.GetKeyDown(KeyCode.X))

        {

//Debug.Log("Dance");

//toggle dancing with X key

danceBool = !danceBool;

_animator.SetBool(_animIDDance, danceBool);

_animator.applyRootMotion = danceBool;

}

}






Comments

Popular posts from this blog

guy

magenta girl

Culture today (work in progress)