Two Animations With One Button Press

Hi!

What I am trying to achieve is being able to press one button to activate/deactivate an animation.

I have two animations, a jetpack activate and a jetpack de-activate.

All I want to do is trigger each animation with one button press :smiley:

I’m not really sure how I could go about doing this :confused:

I have been using:

animation.CrossFade(“jetpackActivate”)
animation.CrossFade(“jetpackDe-activate”)

Thank you in advance :smiley:

var activated = false;

function Update()
{
  if (Input.GetButton("jetpack"))
  {
   activated = !activated;
   if (activated)
     animation.Crossfade("jetpackActivate");
   else
     animation.CrossFade("jetpackDe-activate")
  }
}

Set up ‘jetpack’ in the Input Manager (Edit/Project Settings/Input)