Search Unity

Keep Button Pressed State

Discussion in 'Animation' started by madguru, Mar 21, 2014.

  1. madguru

    madguru

    Joined:
    Nov 1, 2013
    Posts:
    7
    Using the Third Person Character from Unity, I have added some animations. For some of them, when I press the activation button 'w', I want the weapon to come out and stay in that state, until I press 'w' again to make it go back.

    This animation is triggered in animator by setting a boolean variable to true when the button is pressed. So essentially, I need that value to stay true and only go back to false when I press 'w' again.

    How can I do this?

    Currently UpAnimator() contains this line:

    Code (csharp):
    1. animator.SetBool ("weapon", weaponInput);
    I imagine I need to add some line of code here. I did see an example that seems along these lines, but I am not sure how to adapt it.

    http://answers.unity3d.com/questions/375356/keep-crouched-until-button-pressed-again-javascrip.html

    I am using C# btw.

    Thank you,

    Adnan Hussain
    http://www.madguru.com