Animation depending on int

I have made a cannon that fires at a certain strenght depending on how long you hold down the space key. What I want is for the cannons “charge” animation to depend on the actual charge int. So the animation will only reach it’s end if you charge the cannon to maximum power. Any tips on how to do this?

How about this?

animation["NameOfAnimation"].normalizedTime = currentPower / maxPower;

Put this in Update, and it will seek through the animation as you charge your cannon!